#include using namespace std; #ifdef LOCAL #include "./library/misc/debug.h" #else #define debug(...) 42 #endif // LOCAL struct ChronoTimer { std::chrono::high_resolution_clock::time_point st; ChronoTimer() { reset(); } void reset() { st = std::chrono::high_resolution_clock::now(); } std::chrono::milliseconds::rep elapsed() { auto ed = std::chrono::high_resolution_clock::now(); return std::chrono::duration_cast(ed - st) .count(); } }; int main() { #ifdef LOCAL ChronoTimer chrono; #endif std::cin.tie(nullptr)->sync_with_stdio(false); std::cout << fixed << setprecision(12); int T = 1; std::cin >> T; while (T--) { long long V, X, F, F1, Q, R; std::cin >> V >> X >> F >> F1 >> Q >> R; if (X + F1 * R - F * R > V) { std::cout << "Overflow\n"; continue; } long long A = F * Q; long long B = F1 * R; long long dif = B - A; if (dif == 0) { std::cout << "Safe\n"; } else if (dif > 0) { std::cout << "Overflow\n"; } else { std::cout << "Zero\n"; } } #ifdef LOCAL cout << "\nRunning Time:" << chrono.elapsed() << "ms\n"; #endif }