#include using std::cin; using std::cout; using std::endl; using std::set; using std::map; using std::min; using std::max; using std::vector; using std::deque; using std::queue; using std::min; using std::max; using std::swap; using std::string; using std::sort; using std::unique; typedef long long ll; typedef double db; const int MOD = 998244353; const int N = 1000005; struct Pir { ll x,y; }; ll get_gcd(ll x,ll y) {return (y==0) ? x : get_gcd(y,x%y);} ll power(const ll & x,const ll & mi) { ll s1=1LL,s2=x,m=mi; while (m) { if (m&1) s1=s1*s2%MOD; s2=s2*s2%MOD; m>>=1; } return s1; } inline ll get_inv(ll x) { return power(x,MOD - 2); } struct Node_ { int atk,hp,cas; }; Node_ calc(int atk1,int hp1,int atk2,int hp2) { int t=0; while (hp1>0 && hp2>0) { ++t; hp1-=atk2; hp2-=atk1; } if (hp1<1 && hp2<1) return (Node_){0,0,t}; if (hp1<1) return (Node_){atk2,hp2,t}; return (Node_){atk1,hp1,t}; } #define eps (1e-9) void solve() { int x,y,z; cin>>x>>y>>z; if (x>y) swap(x,y); if (x>z) swap(x,z); if (y>z) swap(y,z); if (x>y) swap(x,y); if (x>z) swap(x,z); if (y>z) swap(y,z); if (x>y) swap(x,y); if (x>z) swap(x,z); if (y>z) swap(y,z); int ans=MOD; Node_ t; t=calc(x,1000,y,1000); ans=min(ans,t.cas+calc(z,1000,t.atk,t.hp).cas); t=calc(x,1000,z,1000); ans=min(ans,t.cas+calc(y,1000,t.atk,t.hp).cas); t=calc(y,1000,z,1000); ans=min(ans,t.cas+calc(x,1000,t.atk,t.hp).cas); for (int i=0;;++i) { int hp=max(1000-i*z,0),cas1=i,cas2; cas2=(int)(1.0*hp/y+1-eps); ans=min(ans,cas1+cas2+calc(y,1000-x*cas2,z,1000-x*cas1).cas); if (i*z>=1000) break; } cout<>T; while (T--) solve(); return 0; }