#include #define Max(a,b) ((ab)&&(a=b)) #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) #define erep(i,a) for(int i=hd[a],y;(y=to[i]);i=nxt[i]) using namespace std; typedef long long ll; char C; inline int rd() { int res=0,f=1; while(C=getchar(),C<48||C>57)if(C=='-')f=0; do res=(res<<3)+(res<<1)+(C^48); while(C=getchar(),C>=48&&C<=57); if(f)return res; return -res; } int main() { int T=rd(); while(T--) { int a=rd(),b=rd(),c=rd(),ans=1e6; int i=0; while(1) { int aa=1000-i*b,bb=1000-i*a,cc=1000; int t1=(aa-1)/c+1,t2=(bb-1)/c+1; if(aa<=0)t1=0; if(bb<=0)t2=0; if((t1-1)*a+t2*b<1000||t1*a+(t2-1)*b<1000)Min(ans,i+t1+t2); if(aa<=0||bb<=0)break; i++; } i=0; swap(b,c); while(1) { int aa=1000-i*b,bb=1000-i*a,cc=1000; int t1=(aa-1)/c+1,t2=(bb-1)/c+1; if(aa<=0)t1=0; if(bb<=0)t2=0; if((t1-1)*a+t2*b<1000||t1*a+(t2-1)*b<1000)Min(ans,i+t1+t2); if(aa<=0||bb<=0)break; i++; } swap(a,c); i=0; while(1) { int aa=1000-i*b,bb=1000-i*a,cc=1000; int t1=(aa-1)/c+1,t2=(bb-1)/c+1; if(aa<=0)t1=0; if(bb<=0)t2=0; if((t1-1)*a+t2*b<1000||t1*a+(t2-1)*b<1000)Min(ans,i+t1+t2); if(aa<=0||bb<=0)break; i++; } cout<