#include using namespace std; const int nmax=2e5+42,inf=1e8; int inp[nmax]; pair holes[nmax]; mt19937 rng(42); int x_[4]={0,-1,0,+1}; int y_[4]={-1,0,+1,0}; char c[4]={'L','U','R','D'}; int n,k,s,w,z,x,y; bool valid(int pos) { return 1<=pos&&pos<=n; } map< pair,int > seen; void update() { for(int i=1;i<=k;i++) { holes[i].first=(1LL*holes[i].first*w+z)%n+1; holes[i].second=(1LL*holes[i].second*z+w)%n+1; //cout<<"hole "< moves; double mx_score; vector moves_now; vector< pair > been; void dfs(int x_now,int y_now,int which,int score_now) { if(which&&1.0*score_now/which>mx_score) { mx_score=1.0*score_now/which; moves=moves_now; } if(which>=LIM)return; for(int i=0;i<4;i++) { if(moves_now.size()&&moves_now.back()!=i&&moves_now.back()%2==i%2)continue; int x_new=x_now+x_[i]; int y_new=y_now+y_[i]; int add=eval(x_new,y_new); for(auto w:been) if(w==make_pair(x_new,y_new))add=0; been.push_back({x_new,y_new}); moves_now.push_back(i); dfs(x_new,y_new,which+1,score_now+add); moves_now.pop_back(); been.pop_back(); } } int main() { freopen("cleanUP.in","r",stdin); freopen("cleanUP.out","w",stdout); int high=4; scanf("%i%i%i%i%i%i%i",&n,&k,&s,&w,&z,&x,&y); for(int i=0;i<=(n-1)*sqrt(2.0);i++)scanf("%i",&inp[i]); for(int j=1;j<=k;j++)scanf("%i%i",&holes[j].first,&holes[j].second); //if(n<=100&&s<=1000)high=6; for(int t=0;t<=s;t++) { //cout<<"t= "<