#include #include using namespace std; using i32 = int; using i64 = long long; using i128 = __int128_t; using f64 = double; using p2 = pair; using p3 = tuple; using mint = atcoder::modint998244353; constexpr i64 inf = 1e18; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); _main(); } void _main() { i64 t; cin >> t; for (;t--;) { i64 n, x, y, a, b; cin >> n >> x >> y >> a >> b; assert(n <= 10); while (n > 0) { if (x + y < 0) x += a; else y -= b; n--; } cout << x << " " << y << "\n"; } }