// Devarshi
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int maxn=1000001;
bool cw(pair<int,pair<ld,ld> > a,pair<int,pair<ld,ld> > b,pair<int,pair<ld,ld> > c){
return a.se.fi*(b.se.se-c.se.se)+b.se.fi*(c.se.se-a.se.se)+c.se.fi*(a.se.se-b.se.se) < 0;
}
bool ccw(pair<int,pair<ld,ld> > a,pair<int,pair<ld,ld> > b,pair<int,pair<ld,ld> > c){
return a.se.fi*(b.se.se-c.se.se)+b.se.fi*(c.se.se-a.se.se)+c.se.fi*(a.se.se-b.se.se) > 0;
}
bool cmp(pair<int,pair<ld,ld> > a,pair<int,pair<ld,ld> > b){
if(a.se.se==b.se.se && a.se.fi!=b.se.fi) return a.se.fi<b.se.fi;
if(a.se.fi==b.se.fi) return a.fi<b.fi;
return a.se.se<b.se.se;
}
ld dist(pair<int,pair<ld,ld> > a,pair<int,pair<ld,ld> > b){
ld x=a.se.fi-b.se.fi;
x*=x;
ld y=b.se.se-a.se.se;
y*=y;
return sqrt(x+y);
}
int main(){
sync
/*
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
*/
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<pair<int,pair<ld,ld> > > pts(n);
map< pair<ld,ld> ,int > m;
forn(i,n) {
pts[i].fi = i+1;
cin>>pts[i].se.fi;
cin>>pts[i].se.se;
if(m.find(mp(pts[i].se.fi,pts[i].se.se))==m.end()){
m[mp(pts[i].se.fi,pts[i].se.se)]=i+1;
}
}
sort(all(pts),cmp);
pair<int,pair<ld,ld> > a,b;
a.fi=pts[0].fi;
a.se.se=pts[0].se.se;
a.se.fi=pts[0].se.fi;
b.fi=pts[n-1].fi;
b.se.se=pts[n-1].se.se;
b.se.fi=pts[n-1].se.fi;
vector<pair<int,pair<ld,ld> >> up,down;
up.pb(a);
down.pb(a);
fore(i,1,n-1){
// pair <int,int> p(pts[i].se.fi,pts[i].se.se);
if(i==n-1||cw(a,pts[i],b)){
while(up.size()>=2 && !cw(up[up.size()-2],up[up.size()-1],pts[i])){
up.pop_back();
}
up.pb(pts[i]);
}
if(i==n-1||ccw(a,pts[i],b)){
while(down.size()>=2 && !ccw(down[down.size()-2],down[down.size()-1],pts[i])){
down.pop_back();
}
down.pb(pts[i]);
}
}
reverse(all(up));
vector<pair<int,pair<ld,ld> > > ans;
ld peri = 0;
fore(i,1,down.size()-1){
peri += dist(down[i],down[i-1]);
}
fore(i,1,up.size()-1){
peri += dist(up[i],up[i-1]);
}
cout<<fixed<<setprecision(2)<<peri<<endl;
for(auto it:down){
cout<<m[mp(it.se.fi,it.se.se)]<<" ";
}
fore(i,1,up.size()-2){
cout<<m[mp(up[i].se.fi,up[i].se.se)]<<" ";
}
cout<<endl<<endl;
}
return 0;
}
Ly8gRGV2YXJzaGkKCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG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