#include using namespace std; #define nl '\n' using ll = long long; #ifdef LOCAL #include "algo/debug.h" #else #define dbg(...) #endif void solve() { int V, X, Fo, Fi, Q, R; cin >> V >> X >> Fo >> Fi >> Q >> R; int cur = X; for (int t = 1; t < 10100; ++t) { if (t % Q < R) { cur += Fi; } cur -= Fo; dbg(t, cur); if (cur > V) { cout << "Overflow" << nl; return; } if (cur <= 0) { cout << "Zero" << nl; return; } } cout << "Safe" << nl; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int tc = 1; cin >> tc; while (tc--) { solve(); } }