#include #include using namespace std; using ll = long long; void solve (ll V, ll X, int Fo, int Fi, int Q, int R) { // 制約を見落としていた。R < Qが常に成立。 ll trace = (1LL * R * Fi + X) - (1LL * R * Fo); if (V < trace) { cout << "Overflow\n"; return; } trace -= 1LL * (Q-R-1) * Fo; if (trace < 0) { cout << "Zero\n"; return; } ll inflow = 1LL * R * Fi; ll outflow = 1LL * Q * Fo; if (inflow == outflow) { cout << "Safe\n"; return; } if (inflow < outflow) { cout << "Zero\n"; return; } if (outflow < inflow) { cout << "Overflow\n"; return; } assert(0); } int main () { int T; cin >> T; while (T--) { ll V, X; cin >> V >> X; int Fo, Fi; cin >> Fo >> Fi; int Q, R; cin >> Q >> R; solve(V, X, Fo, Fi, Q, R); } return 0; }