/** * *----------AC be here!----------/ *    ┏┓   ┏┓ *   ┏┛┻━━━┛┻┓ *   ┃       ┃ *   ┃   ━   ┃ *   ┃ ┳┛ ┗┳ ┃ *   ┃       ┃ *   ┃   ┻   ┃ *   ┃       ┃ *   ┗━┓   ┏━┛ *     ┃   ┃神兽保佑 *     ┃   ┃代码无BUG! *     ┃   ┗━━━┓ *     ┃       ┣┓ *     ┃       ┏┛ *     ┗┓┓┏━┳┓┏┛ *      ┃┫┫ ┃┫┫ *      ┗┻┛ ┗┻┛ * ━━━━━━神兽出没━━━━━━by:刺猬他想被拥抱 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define fi first #define se second #define clr(a, b) memset(a, b, sizeof(a)) typedef long long ll; typedef double db; typedef pair Pii; typedef pair Pdd; const int PI = acos(-1.0); const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; //freopen("test.in", "r", stdin); //freopen("test.out", "r", stdout); const int _K=50268147,_B=6082187,_P=100000007; int _X; inline int get_rand(int _l,int _r){ _X=((long long)_K*_X+_B)%_P; return _X%(_r-_l+1)+_l; } int n,m,k,seed; int x[1000006],y[1000006]; int cntx[1000006], cnty[1000006]; void Init(){ scanf("%d%d%d%d",&n,&m,&k,&seed); _X=seed; for (int i=1;i<=k;++i) x[i]=get_rand(1,n), y[i]=get_rand(1,m); } int T; int main() { scanf("%d",&T); while(T--) { Init(); clr(cntx, 0); clr(cnty, 0); for(int i = 1; i <= k; i++) { cntx[x[i]]++; cnty[y[i]]++; } int a1 = 0, a2 = 0; for(int i = 1; i <= n; i++) { if(cntx[i]) a1++; } for(int i = 1; i <= m; i++) { if(cnty[i]) a2++; } printf("%d %d\n", n - a1, m - a2); } return 0; }