import java.util.*; import java.io.*; public class PolyCube { Scanner in = new Scanner(System.in); ArrayList cubes; class Cube { public int x,y,z; public Cube(int mx, int my, int mz) { x = mx; y = my; z = mz; } private int temp(int x1, int x2) { int diff = Math.abs(x1 - x2); if(diff > 1) return -1; return diff; } public boolean sharesFace(Cube c) { int t1 = temp(x,c.x); if(t1 < 0) return false; int t2 = temp(y,c.y); if(t2 < 0) return false; int t3 = temp(z,c.z); if(t3 < 0) return false; int ans = t1+t2+t3; if(ans >= 2) return false; return true; } public boolean equals(Cube c) { if(x == c.x && y == c.y && z == c.z) return true; return false; } public String toString() { return "(" + x + "," + y + "," + z + ")"; } } public int numShared(Cube c) { int ans = 0; for(Cube c2 : cubes) { if(c.sharesFace(c2)) { ans++; //System.out.println(c + " shares with " + c2); } } return ans; } public int changeInArea(int faces_shared) { switch(faces_shared) { case 0: return 6; case 1: return 4; case 2: return 2; case 3: return 0; case 4: return -2; case 5: return -4; default: return -6; } } public static void main(String[] args) { new PolyCube().solve(); } public void solve() { //in = new Scanner("4\n5\n0,0,0 0,0,1 0,0,2 0,0,3 0,0,4\n8\n0,0,0 0,0,1 0,1,0 0,1,1 1,0,0 1,0,1 1,1,0 1,1,1\n4\n0,0,0 0,0,1 1,1,0 1,1,1\n20\n0,0,0 0,0,1 0,0,2 0,1,2 0,2,2 0,2,1 0,2,0 0,1,0 1,0,0 2,0,0 1,0,2 2,0,2 1,2,2 2,2,2 1,2,0 2,2,0 2,1,0 2,1,2 2,0,1 2,2,1"); cubes = new ArrayList(); int num_cases = Integer.parseInt(in.nextLine()); for(int case_num = 1; case_num <= num_cases; case_num++) { int num_cubes = Integer.parseInt(in.nextLine()); String[] cubes_str = new String[num_cubes]; int c_index = 0; for(int i=0; i