#include <bits/stdc++.h>
using namespace std;
#define int long long
struct point
{
int x,y,f,id;
point operator-(const point &b)const
{
point c;
c.x=x-b.x;
c.y=y-b.y;
return c;
}
int operator*(const point &b)const
{
return x*b.y-y*b.x;
}
}p[2010],np[2010],hul[2010];
int st[2010],vis[2010];
inline bool kless(point a1,point a2,point b1,point b2)
{
return (a2.x-a1.x)*(b2.y-b1.y)>(a2.y-a1.y)*(b2.x-b1.x);
}
bool check(point a1,point a2,point b1,point b2)
{
}
void solve()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int x,y,f;
cin>>x>>y>>f;
p[i]={x,y,f,id};
}
sort(p+1,p+n+1,[](point i,point j){return (i.x!=j.x?i.x<j.x:i.y<j.y);});
for(int i=1;i<=n;i++)
{
fill(vis+1,vis+n+1,0);
int f=p[i].f,cnt=0;
for(int j=1;j<i;j++) if(p[j].f!=f) np[++cnt]=p[j];
if(!cnt) continue;
int top=0;
st[++top]=1;
vis[1]=1;
for(int j=2;j<=cnt;j++)
{
if(top>1&&(np[st[top]]-np[st[top-1]])*(np[j]-np[st[top]])<=0) vis[top--]=0;
st[++top]=j;
vis[j]=1;
}
int sz=top;
for(int j=cnt-1;j;j--)
{
if(vis[j]) continue;
if(top>sz&&(np[st[top]]-np[st[top-1]])*(np[j]-np[st[top]])<=0) vis[top--]=0;
st[++top]=j;
vis[j]=1;
}
for(int j=1;j<top;j++) hul[j]=np[st[j]];
int mny=1e18,mnpos,mxy=-1e18,mxpos;
for(int j=1;j<top;j++)
{
int y=hul[j].y;
if(y<mny)
{
mny=y;
mnpos=j;
}
if(y>mxy)
{
mxy=y;
mxpos=j;
}
}
for(int j=1;j<i;j++)
{
if(p[j].f!=f) continue;
if(kless(p[j],p[i],hul[mxpos],p[i])||kless(hul[mnpos],p[i],p[j],p[i])) continue;
int l=mnpos,r=mxpos-1,mid,res=l;
while(l<=r)
{
mid=l+r>>1;
if(kless(p[j],p[i],hul[mid],p[i])) res=mid,l=mid+1;
else r=mid-1;
}
if(check(hul[res],hul[res+1],p[i],p[j]))
{
cout<<"4\n"<<p[i].id<<' '<<hul[res+1].id<<' '<<p[j].id<<' '<<<hul[res].id<<'\n';
return;
}
}
}
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}