# include using namespace std; # define rep(i,a,n) for (int i=a; i<=n; ++i) # define per(i,a,n) for (int i=a; i>=n; --i) # define bug puts("H"); # define pb push_back # define mp make_pair # define all(x) (x).begin(), (x).end() # define SZ(x) (int)x.size() # define fi first # define se second # define lch p<<1,l,mid # define rch p<<1|1,mid+1,r # define mem(a,b) memset(a,b,sizeof(a)) # define INF 1000000001 # define MOD 1000000007 typedef vector Vi; typedef long long i64; typedef pair Pi; i64 powmod(i64 a, i64 b){i64 res=1;a%=MOD;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;} i64 Inv(i64 b){return powmod(b,(i64)MOD-2);} const int N = 1005; const double eps = 1e-9; const double inf = 1e18; int ce(int x, int y) {return (x+y-1)/y;} int main () { int T; scanf("%d", &T); while (T--) { int x, y, z; scanf("%d%d%d", &x, &y, &z); int ans = INF; rep(a,0,min(ce(1000,x), ce(1000,y))) { int vx = max(0, 1000 - a*y); int vy = max(0, 1000 - a*x); if (vx == 0 && vy == 0) ans = min(ans, a); rep(b,0,min(ce(vy,z), ce(1000,y))) { int vvy = max(0, vy - b*z); int vvz = max(0, 1000 - b*y); if (vx+vvy==0 || vx+vvz==0 || vvy+vvz==0) ans = min(ans, a+b); else { int c = min(ce(vx,z), ce(vvz,x)); int vvvx = max(0, vx-c*z); int vvvz = max(0, vvz-c*x); if (vvvx+vvy==0 || vvvx+vvvz==0 || vvy+vvvz==0) ans = min(ans, a+b+c); } } } printf("%d\n", ans); } return 0; }