#include <iostream>
using namespace std;
const int nmax=10005;
const int vmax=10;
int n, x[nmax], y[nmax], q, xo, yo, vxo, vyo, ax, bx, ay, by, avx, bvx, avy, bvy;
pair<int,int> cl[2*vmax+1][2*vmax+1][nmax];
int pos, ans;
void QSort(int L, int R, pair<int,int> A[]);
int Left(int u, int v, int e);
int Right(int u, int v, int e);
int Less(int u, int v, int L, int R, int val);
int More(int u, int v, int L, int R, int val);
int main()
{
scanf("%d\n",&n);
for(int i=1;i<=n;i++) scanf("%d %d\n",&x[i],&y[i]);
for(int i=0;i<=2*vmax;i++)
for(int j=0;j<=2*vmax;j++)
{
for(int k=1;k<=n;k++)
{
cl[i][j][k].first=x[k]*(j-vmax)-y[k]*(i-vmax);
cl[i][j][k].second= j==vmax ? x[k]:y[k];
}
QSort(1, n, cl[i][j]);
}
scanf("%d\n",&q);
scanf("%d %d %d %d\n",&xo, &yo, &vxo, &vyo);
scanf("%d %d %d %d %d %d %d %d\n",&ax, &bx, &ay, &by, &avx, &bvx, &avy, &bvy);
ax=ax % 20001;
bx=bx % 20001;
ay=ay % 20001;
by=by % 20001;
avx=avx % 21;
bvx=bvx % 21;
avy=avy % 21;
bvy=bvy % 21;
pos=1, ans=0;
for(int t=1;t<=q;t++)
{
if(t>1)
{
xo= xo % 20001;
if(xo<0) xo+=20001;
yo= yo % 20001;
if(yo<0) yo+=20001;
bx= bx % 20001;
if(bx<0) bx+=20001;
by= by % 20001;
if(by<0) by+=20001;
xo=(ax*(xo+10000)+bx) % 20001 - 10000;
yo=(ay*(yo+10000)+by) % 20001 - 10000;
vxo=(avx*(vxo+10)+bvx) % 21 - 10;
vyo=(avy*(vyo+10)+bvy) % 21 - 10;
}
int i=vxo+vmax, j=vyo+vmax;
int e=xo*vyo-yo*vxo;
int alpha=Left(i, j, e), beta=Right(i, j, e);
if(alpha==-1) continue;
int now=0, ind;
if(vyo==0)
{
if(vxo>0)
{
ind=More(i,j,alpha,beta,xo);
if(ind!=-1) now=beta-ind+1;
}
else
{
ind=Less(i,j,alpha,beta,xo);
if(ind!=-1) now=ind-alpha+1;
}
}
else
{
if(vyo>0)
{
ind=More(i,j,alpha,beta,yo);
if(ind!=-1) now=beta-ind+1;
}
else
{
ind=Less(i,j,alpha,beta,yo);
if(ind!=-1) now=ind-alpha+1;
}
}
if(now>=ans) ans=now, pos=t;
}
printf("%d %d",pos, ans);
return 0;
}
void QSort(int L, int R, pair<int,int> A[])
{
pair<int,int> X=A[(L+R)/2], Y;
int i=L, j=R;
while(i<=j)
{
while(A[i].first<X.first || A[i].first==X.first && A[i].second<X.second) i++;
while(A[j].first>X.first || A[j].first==X.first && A[j].second>X.second) j--;
if(i<=j)
{
Y=A[i], A[i]=A[j], A[j]=Y;
i++, j--;
}
}
if(L<j) QSort(L, j, A);
if(i<R) QSort(i, R, A);
}
int Left(int u, int v, int e)
{
int L=1, R=n, mid;
while(R-L>1)
{
mid=(L+R)/2;
if(cl[u][v][mid].first<e) L=mid;
else R=mid;
}
if(cl[u][v][L].first==e) return L;
if(cl[u][v][R].first==e) return R;
return -1;
}
int Right(int u, int v, int e)
{
int L=1, R=n, mid;
while(R-L>1)
{
mid=(L+R)/2;
if(cl[u][v][mid].first<=e) L=mid;
else R=mid;
}
if(cl[u][v][R].first==e) return R;
if(cl[u][v][L].first==e) return L;
return -1;
}
int Less(int u, int v, int L, int R, int val)
{
int mid;
while(R-L>1)
{
mid=(L+R)/2;
if(cl[u][v][mid].second<=val) L=mid;
else R=mid;
}
if(cl[u][v][R].second<=val) return R;
if(cl[u][v][L].second<=val) return L;
return -1;
}
int More(int u, int v, int L, int R, int val)
{
int mid;
while(R-L>1)
{
mid=(L+R)/2;
if(cl[u][v][mid].second>=val) R=mid;
else L=mid;
}
if(cl[u][v][L].second>=val) return L;
if(cl[u][v][R].second>=val) return R;
return -1;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG5tYXg9MTAwMDU7CmNvbnN0IGludCB2bWF4PTEwOwoKaW50IG4sIHhbbm1heF0sIHlbbm1heF0sIHEsIHhvLCB5bywgdnhvLCB2eW8sIGF4LCBieCwgYXksIGJ5LCBhdngsIGJ2eCwgYXZ5LCBidnk7CnBhaXI8aW50LGludD4gY2xbMip2bWF4KzFdWzIqdm1heCsxXVtubWF4XTsKaW50IHBvcywgYW5zOwoKdm9pZCBRU29ydChpbnQgTCwgaW50IFIsIHBhaXI8aW50LGludD4gQVtdKTsKaW50IExlZnQoaW50IHUsIGludCB2LCBpbnQgZSk7CmludCBSaWdodChpbnQgdSwgaW50IHYsIGludCBlKTsKaW50IExlc3MoaW50IHUsIGludCB2LCBpbnQgTCwgaW50IFIsIGludCB2YWwpOwppbnQgTW9yZShpbnQgdSwgaW50IHYsIGludCBMLCBpbnQgUiwgaW50IHZhbCk7CgoKaW50IG1haW4oKQp7CiAgc2NhbmYoIiVkXG4iLCZuKTsKICBmb3IoaW50IGk9MTtpPD1uO2krKykgc2NhbmYoIiVkICVkXG4iLCZ4W2ldLCZ5W2ldKTsKICAKICBmb3IoaW50IGk9MDtpPD0yKnZtYXg7aSsrKQogICAgZm9yKGludCBqPTA7ajw9Mip2bWF4O2orKykKICAgIHsKICAgICAgICBmb3IoaW50IGs9MTtrPD1uO2srKykKICAgICAgICB7CiAgICAgICAgICAgIGNsW2ldW2pdW2tdLmZpcnN0PXhba10qKGotdm1heCkteVtrXSooaS12bWF4KTsKICAgICAgICAgICAgY2xbaV1bal1ba10uc2Vjb25kPSBqPT12bWF4ID8geFtrXTp5W2tdOwogICAgICAgIH0KICAgICAgICBRU29ydCgxLCBuLCBjbFtpXVtqXSk7CiAgICB9CiAgICAKICBzY2FuZigiJWRcbiIsJnEpOwogIHNjYW5mKCIlZCAlZCAlZCAlZFxuIiwmeG8sICZ5bywgJnZ4bywgJnZ5byk7CiAgc2NhbmYoIiVkICVkICVkICVkICVkICVkICVkICVkXG4iLCZheCwgJmJ4LCAmYXksICZieSwgJmF2eCwgJmJ2e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0tMSkgbm93PWJldGEtaW5kKzE7CiAgICAgIH0KICAgICAgZWxzZQogICAgICB7CiAgICAgICAgaW5kPUxlc3MoaSxqLGFscGhhLGJldGEseG8pOwogICAgICAgIGlmKGluZCE9LTEpIG5vdz1pbmQtYWxwaGErMTsKICAgICAgfQogICAgfQogICAgZWxzZQogICAgewogICAgICBpZih2eW8+MCkKICAgICAgewogICAgICAgIGluZD1Nb3JlKGksaixhbHBoYSxiZXRhLHlvKTsKICAgICAgICBpZihpbmQhPS0xKSBub3c9YmV0YS1pbmQrMTsKICAgICAgfQogICAgICBlbHNlCiAgICAgIHsKICAgICAgICBpbmQ9TGVzcyhpLGosYWxwaGEsYmV0YSx5byk7CiAgICAgICAgaWYoaW5kIT0tMSkgbm93PWluZC1hbHBoYSsxOwogICAgICB9CiAgICB9CiAgICBpZihub3c+PWFucykgYW5zPW5vdywgcG9zPXQ7CiAgfQogIAogIHByaW50ZigiJWQgJWQiLHBvcywgYW5zKTsKCiAgcmV0dXJuIDA7Cn0KCgoKCnZvaWQgUVNvcnQoaW50IEwsIGludCBSLCBwYWlyPGludCxpbnQ+IEFbXSkKewogIHBhaXI8aW50LGludD4gWD1BWyhMK1IpLzJdLCBZOwogIGludCBpPUwsIGo9UjsKICB3aGlsZShpPD1qKQogIHsKICAgIHdoaWxlKEFbaV0uZmlyc3Q8WC5maXJzdCB8fCBBW2ldLmZpcnN0PT1YLmZpcnN0ICYmIEFbaV0uc2Vjb25kPFguc2Vjb25kKSBpKys7CiAgICB3aGlsZShBW2pdLmZpcnN0PlguZmlyc3QgfHwgQVtqXS5maXJzdD09WC5maXJzdCAmJiBBW2pdLnNlY29uZD5YLnNlY29uZCkgai0tOwogICAgaWYoaTw9aikKICAgIHsKICAgICAgWT1BW2ldLCBBW2ldPUFbal0sIEFbal09WTsKICAgICAgaSsrLCBqLS07CiAgICB9CiAgfQogIGlmKEw8aikgUVNvcnQoTCwgaiwgQSk7CiAgaWYoaTxSKSBRU29ydChpLCBSLCBBK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