#include #include using namespace std; #define rep(i, x, limit) for (long long i = (long long)x; i < (long long)limit; i++) #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define el '\n' #define spa " " #define Yes cout << "Yes" << el #define No cout << "No" << el #define YES cout << "YES" << el #define NO cout << "NO" << el #define inp(x) for(auto &i:x)cin>>i #define eps (1e-10) #define Equals(a,b) (fabs((a) - (b)) < eps ) #define debug(x) cerr << #x << " = " << x << el using ll = long long; using ull = unsigned long long; using i128 = __int128_t; using boost::multiprecision::cpp_int; using pii = pair; using pll = pair; using vi = vector; using vl = vector; using vvl = vector>; using vs = vector; using vb = vector; const double pi = 3.141592653589793238; const int inf = 1073741823; const ll infl = 1LL << 60; const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string abc = "abcdefghijklmnopqrstuvwxyz"; const ll MOD = 998244353; #include using namespace atcoder; using mint = modint998244353; using vm = vector; pll F(ll n,ll x,ll y,ll a, ll b){ ll m=x+y; if(a<=0&&b<=0){ if(m>=0)return {x,y-b*n}; else return {x+a*n,y}; }if(a<=0){ if(m<0)return {x+a*n,y}; else{ ll t=m/b+1; if(t>=n)return {x,y-b*n}; else return {x+a*(n-t),y-b*t}; } }if(b<=0){ if(m>=0)return {x,y-b*n}; else{ ll t=(-m-1)/a+1; if(t>=n)return {x+a*n,y}; else return {x+a*t,y-b*(n-t)}; } }else{ ll l=0,r=n+1; while(r-l>1){ ll mid=(l+r)/2; ll stc=m+a*mid-b*(n-mid); if(stc>t; while(t--){ ll n,x,y,a,b;cin>>n>>x>>y>>a>>b; pll ans=F(n,x,y,a,b); cout<