#include int main(){ int n,a[10000],b[10000],c[10000],ans[10000],x; int A,B,C; scanf("%d\n",&n); for(int i = 0;i < n;i++){ scanf("%d %d %d",&a[i],&b[i],&c[i]); } for(int i = 0;i < n;i++){ if((a[i] == b[i])&&(a[i] == c[i])){ ans[i] = 3; //printf("flag:C\n"); }else if( ((b[i] > a[i])&&(a[i] > c[i]))|| ((b[i] > c[i])&&(c[i] > a[i]))|| ((a[i] > c[i])&&(c[i] > b[i]))|| ((c[i] > a[i])&&(c[i] > a[i]))){ ans[i] = 0; //printf("flag:A\n"); }else if(a[i] + b[i] + c[i] <= 6){ ans[i] = -1; //printf("flag:B\n"); }else { if((a[i] < b[i])&&(b[i] > c[i])){ x = c[i]; c[i] = b[i]; b[i] = x; }else if((b[i] > a[i])&&(a[i] > c[i])){ x = a[i]; a[i] = b[i]; b[i] = x; }else if((b[i] > c[i])&&(c[i] > a[i])){ x = a[i]; a[i] = b[i]; b[i] = x; x = c[i]; c[i] = b[i]; b[i] = x; }else if((c[i] > a[i])&&(a[i] > b[i])){ x = a[i]; a[i] = c[i]; c[i] = x; x = c[i]; c[i] = b[i]; b[i] = x; }else if((c[i] > b[i])&&(b[i] > a[i])){ x = a[i]; a[i] = c[i]; c[i] = x; } a[i] = A; b[i] = B; c[i] = C; ans[i] = A-C; if(A-C == C)ans[i]++; if(ans[i] > A-B)ans[i] == A-B; if(A-B == B)ans[i]++; //printf("flag:D\n"); } printf("%d\n",ans[i]); } }