#include using namespace std; const int maxn = 1000010; const int INF = 0x7fffffff; const int _K=50268147,_B=6082187,_P=100000007; int _X; bitsetbts1,bts2; 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]; 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); bts1[x[i]] = 1; bts2[y[i]] = 1; // cout<>T; while(T--){ bts1.reset(); bts2.reset(); Init(); int ans1=0,ans2=0; for(int i=1;i<=n;i++) if(bts1[i]) ans1++; for(int i=1;i<=m;i++) if(bts2[i]) ans2++; printf("%d %d\n",n-ans1,m-ans2); } return 0; }