#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;
#define loop(n)  for(int i=0;i<n;i++)
#define endl '\n'
typedef long long ll;
int cnt,res,m_x,ans;
int main(){
cin.tie(0);
cin.sync_with_stdio(0);
int r,c,k,q;
cin>>r>>c>>k>>q;
pair<ll,ll>p[k];
loop(k){
int x,y;
cin>>x>>y;
p[i] = make_pair(--x,--y);
}
loop(q){
    int x,y;
    cin>>x>>y;
    --x,--y;
    int ans = (x) * c + y + 1;
for(int j=0;j<k;j++){
    if(p[j].first==(x)&&p[j].second==(y)){
        ans = -1;
        break;
    }
    else if (p[j].first<=(x)&&p[j].second<=(y))ans--;
}
if(ans==-1)	cout<<"Waste"<<endl;
else if (ans%3==2)
			cout << "Kiwis"<<endl;
		else if (ans%3==1)
			cout << "Carrots"<<endl;
		else
			cout << "Grapes"<<endl;
ans = 0;
}

}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,t,w[1009],x,y,h;
set<int> s;
vector<int>v;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        s.insert((x-1)*m+y-1);
    }
    for(set<int>::iterator it=s.begin();it!=s.end();it++,h++)
        w[h]=*it;
    for(int i=0,c=1,o=0;i<n*m;i++)
    {
        if(i==w[o]){
            v.push_back(-1);
            o++;
        }
        else {
            v.push_back(c%3);
            c++;
        }
    }
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        if(v[(x-1)*m+y-1]==1)
            puts("Carrots");
        else if(v[(x-1)*m+y-1]==2)
            puts("Kiwis");
        else if(v[(x-1)*m+y-1]==0)
            puts("Grapes");
        else puts("Waste");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,t,w[80009],x,y;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        w[i]=(x-1)*m+y-1;
    }
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        int c=(x-1)*m+y-1;
        bool flag=false;
        for(int j=0;j<k;j++)
            if(w[j]==(x-1)*m+y-1)
                {puts("Waste");flag=true;break;}
        if(!flag){
            if(c%3==1||c==0)
                puts("Carrots");
            else if(c%3==2)
                puts("Kiwis");
            else if(c%3==0)
                puts("Grapes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,t,w[80009],x,y;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        w[i]=(x-1)*m+y-1;
    }
    sort(w,w+k);
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        int c=(x-1)*m+y-1,cnt=1;
        bool flag=false;
        for(int j=0;j<k;j++)
            if(w[j]==c)
                {puts("Waste");flag=true;break;}
            else if(w[j]<c)
                cnt--;
        if(!flag){
            if((c+cnt)%3==1)
                puts("Carrots");
            else if((c+cnt)%3==2)
                puts("Kiwis");
            else if((c+cnt)%3==0)
                puts("Grapes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,t,w[80009],x,y;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        w[i]=(x-1)*m+y-1;
    }
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        int c=1;
        bool flag=false;
        for(int j=0;j<k;j++)
            if(w[j]==(x-1)*m+y-1)
                {puts("Waste");flag=true;break;}
        if(!flag){
            c=(x-1)*m+y-1;
            if(c%3==1)
                puts("Carrots");
            else if(c%3==2)
                puts("Kiwis");
            else if(c%3==0)
                puts("Grapes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,k,t,w[1009],x,y,h;
set<int> s;
vector<ll>v;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        s.insert((x-1)*m+y-1);
    }
    for(set<int>::iterator it=s.begin();it!=s.end();it++,h++)
        w[h]=*it;
    for(int i=0,c=1,o=0;i<n*m;i++)
    {
        if(i==w[o]){
            v.push_back(-1);
            o++;
        }
        else {
            v.push_back(c%3);
            c++;
        }
    }
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        if(v[(x-1)*m+y-1]==1)
            puts("Carrots");
        else if(v[(x-1)*m+y-1]==2)
            puts("Kiwis");
        else if(v[(x-1)*m+y-1]==0)
            puts("Grapes");
        else puts("Waste");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,k,t,w[1009];
set<ll> s;
vector<ll>v;
int main ()
{
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        s.insert((x-1)*m+y-1);
    }
    int h=0;
    for(set<ll>::iterator it=s.begin();it!=s.end();it++,h++)
        w[h]=*it;
    for(ll i=0,c=1,o=0;i<n*m;i++)
    {
        if(i==w[o]){
            v.push_back(-1);
            o++;
        }
        else {
            v.push_back(c%3);
            c++;
        }
    }
    for(int i=0;i<t;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(v[(x-1)*m+y-1]==1)
            puts("Carrots");
        else if(v[(x-1)*m+y-1]==2)
            puts("Kiwis");
        else if(v[(x-1)*m+y-1]==0)
            puts("Grapes");
        else puts("Waste");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,t,w[1009],x,y,h;
set<int> s;
vector<int>v;
int main ()
{
    freopen("Input.pl","r",stdin);
    freopen("Output.pl","w",stdout);
    scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&x,&y);
        s.insert((x-1)*m+y-1);
    }
    for(set<int>::iterator it=s.begin();it!=s.end();it++,h++)
        w[h]=*it;
    for(int i=0,c=1,o=0;i<n*m;i++)
    {
        if(i==w[o]){
            v.push_back(-1);
            o++;
        }
        else {
            v.push_back(c%3);
            c++;
        }
    }
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&x,&y);
        if(v[(x-1)*m+y-1]==1)
            puts("Carrots");
        else if(v[(x-1)*m+y-1]==2)
            puts("Kiwis");
        else if(v[(x-1)*m+y-1]==0)
            puts("Grapes");
        else puts("Waste");
    }
    return 0;
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define w               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool saved[700009];
int memo[1000][4];
char c;
bool a[40009][40009];
int main() {
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    while(k--)
    {
        int x,y;
        cin>>x>>y;
        a[x][y]=1;
    }
    map<pair<int,int>,string>mp;
    int p=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
           if(!a[i][j])
           {
               if(p==1)
               {
                   mp[make_pair(i,j)]="Carrots";
                   p=2;
               }else if(p==2)
               {
                   mp[make_pair(i,j)]="Kiwis";
                   p=3;
               }else if(p==3)
               {
                   mp[make_pair(i,j)]="Grapes";
                   p=1;
               }
           }else
           {
               mp[make_pair(i,j)]="Waste";
           }
        }
    }
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        cout<<mp[make_pair(x,y)]<<endl;
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define w               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool saved[700009];
int memo[1000][4];
char c;
bool a[40009];
bool b[40009];
int main() {
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    map<pair<int,int>,string>mp;
    while(k--)
    {
        int x,y;
        cin>>x>>y;
        mp[make_pair(x,y)]="Waste";
    }
    int p=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
           if(mp[make_pair(i,j)]!="Waste")
           {
               if(p==1)
               {
                   mp[make_pair(i,j)]="Carrots";
                   p=2;
               }else if(p==2)
               {
                   mp[make_pair(i,j)]="Kiwis";
                   p=3;
               }else if(p==3)
               {
                   mp[make_pair(i,j)]="Grapes";
                   p=1;
               }
           }
        }
    }
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        cout<<mp[make_pair(x,y)]<<endl;
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;

int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        int nc=a*m-(n-b),nw=0;
        nc--;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i].first<=a&&v[i].second<=b)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;

int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(w--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        int nc=(a-1)*m+(b-1),nw=0;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i].first<=a&&v[i].second<=b)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;

int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(w--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        int nc=a*m-(m-b)-1,nw=0;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i].first<=a&&v[i].second<=b)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;

int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(w--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        pair<int,int>p={a,b};
        int nc=(a-1)*m+(b-1),nw=0;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i]<p)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;

int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        int nc=a*m-(m-b)-1,nw=0;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i].first<=a&&v[i].second<=b)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define wt               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool vis[100910];
ll a[100009],h[100009];
int memo[1000009];
int maxk=3;
ll sol;
vector<vector<int>>v(100009);
vector<int>in;
void topsort(int node)
{
    vis[node]=1;
    for(int i=0;i<v[node].size();i++)
    {
        if(!vis[v[node][i]])
            topsort(v[node][i]);
    }
    in.push_back(node);
}
int main() {
    int n,m,w,q;
    cin>>n>>m>>w>>q;
    vector<pair<int,int>>v;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    while(q--)
    {
        bool f=false;
        int a,b;
        cin>>a>>b;
        int nc=a*m-(n-b-1),nw=0;
        for(int i=0;i<v.size();i++)
        {
            if(a==v[i].first&&b==v[i].second)
                f=true;
            if(v[i].first<=a&&v[i].second<=b)
            {
                nw++;
            }
        }
        if(f)
            cout<<"Waste"<<endl;
        else
        {
            int u=((nc-nw)%3+3)%3;
            if(u==0)
                cout<<"Carrots"<<endl;
            else if(u==1)
                cout<<"Kiwis"<<endl;
            else
                cout<<"Grapes"<<endl;
        }
    }
}


#include <bits/stdc++.h>
#include<sstream>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define tc              int t;cin>>t
#define w               while(t--)
typedef long long ll;
typedef pair<int,int> pi;
bool saved[700009];
int memo[1000][4];
char c;
bool a[400][400];
int main() {
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    while(k--)
    {
        int x,y;
        cin>>x>>y;
        a[x][y]=1;
    }
    map<pair<int,int>,string>mp;
    int p=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
           if(!a[i][j])
           {
               if(p==1)
               {
                   mp[make_pair(i,j)]="Carrots";
                   p=2;
               }else if(p==2)
               {
                   mp[make_pair(i,j)]="Kiwis";
                   p=3;
               }else if(p==3)
               {
                   mp[make_pair(i,j)]="Grapes";
                   p=1;
               }
           }else
           {
               mp[make_pair(i,j)]="Waste";
           }
        }
    }
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        cout<<mp[make_pair(x,y)]<<endl;
    }
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

char b[40001][40001];
int main(){
    int n,m,k,t;
    scanf("%d%d%d%d",&n,&m,&k,&t);
    int i,j;
    while(k--){
        scanf("%d%d",&i,&j);
        b[i-1][j-1]='w';
    }
    k=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            if(b[i][j]=='w') continue;
            if(k==3) k=0;
            if(k==0) b[i][j]='c';
            else if(k==1) b[i][j]='k';
            else if(k==2) b[i][j]='g';
            k++;
        }
    while(t--){
        scanf("%d%d",&i,&j);
        i--;j--;
        if(b[i][j]=='w') printf("Waste\n");
        else if(b[i][j]=='c') printf("Carrots\n");
        else if(b[i][j]=='k') printf("Kiwis\n");
        else if(b[i][j]=='g') printf("Grapes\n");
    }

    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int arr[40004];
int main(){
    //read;
    fio;
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    map<pii,bool>mp;
    int a,b;
    arr[1]=0;
    for(int i=2;i<=n;i++) arr[i]=m;
    while(k--){
        cin>>a>>b;
        mp[{a,b}]=1;
        arr[a+1]--;
    }
    for(int i=3;i<=n;i++) arr[i]+=arr[i-1];
    //for(int i=1;i<=n;i++) cout<<i<<" "<<arr[i]<<endl;
    while(t--){
        cin>>a>>b;
        if(mp[{a,b}]) {cout<<"Waste"<<endl;continue;}
        int x=arr[a];
        for(int i=1;i<=b;i++){
            if(mp[{a,i}]) continue;
            x++;
        }
        x%=3;
        if(x==1) cout<<"Carrots";
        else if(x==2) cout<<"Kiwis";
        else if(x==0) cout<<"Grapes";
        cout<<endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int arr[10004];
int main(){
    //read;
    fio;
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    map<pii,bool>mp;
    int a,b;
    arr[1]=0;
    for(int i=2;i<=n;i++) arr[i]=m;
    while(k--){
        cin>>a>>b;
        mp[{a,b}]=1;
        arr[a+1]--;
    }
    for(int i=3;i<=n;i++) arr[i]+=arr[i-1];
    //for(int i=1;i<=n;i++) cout<<i<<" "<<arr[i]<<endl;
    while(t--){
        cin>>a>>b;
        if(mp[{a,b}]) {cout<<"Waste"<<endl;continue;}
        int x=arr[a];
        for(int i=1;i<=b;i++){
            if(mp[{a,i}]) continue;
            x++;
        }
        x%=3;
        if(x==1) cout<<"Carrots";
        else if(x==2) cout<<"Kiwis";
        else if(x==0) cout<<"Grapes";
        cout<<endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int arr[40004];
int main(){
    //read;
    fio;
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    set<pii>st;
    int a,b;
    arr[1]=0;
    for(int i=2;i<=n;i++) arr[i]=m;
    while(k--){
        cin>>a>>b;
        st.insert({a,b});
        arr[a+1]--;
    }
    for(int i=3;i<=n;i++) arr[i]+=arr[i-1];
    //for(int i=1;i<=n;i++) cout<<i<<" "<<arr[i]<<endl;
    while(t--){
        cin>>a>>b;
        if(st.find({a,b})!=st.end()) {cout<<"Waste"<<endl;continue;}
        int x=arr[a];
        for(int i=1;i<=b;i++){
            if(st.find({a,i})!=st.end()) continue;
            x++;
        }
        x%=3;
        if(x==1) cout<<"Carrots";
        else if(x==2) cout<<"Kiwis";
        else if(x==0) cout<<"Grapes";
        cout<<endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
struct HASH{
  template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};
int arr[40004];
int main(){
    //read;
    fio;
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    unordered_map<pii,bool,HASH>mp;
    int a,b;
    arr[1]=0;
    for(int i=2;i<=n;i++) arr[i]=m;
    while(k--){
        cin>>a>>b;
        mp[{a,b}]=1;
        arr[a+1]--;
    }
    for(int i=3;i<=n;i++) arr[i]+=arr[i-1];
    //for(int i=1;i<=n;i++) cout<<i<<" "<<arr[i]<<endl;
    while(t--){
        cin>>a>>b;
        if(mp[{a,b}]) {cout<<"Waste"<<endl;continue;}
        int x=arr[a];
        for(int i=1;i<=b;i++){
            if(mp[{a,i}]) continue;
            x++;
        }
        x%=3;
        if(x==1) cout<<"Carrots";
        else if(x==2) cout<<"Kiwis";
        else if(x==0) cout<<"Grapes";
        cout<<endl;
    }
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

pair<bool,bool> b[40001][40001];
int main(){
    int n,m,k,t;
    scanf("%d%d%d%d",&n,&m,&k,&t);
    int i,j;
    while(k--){
        scanf("%d%d",&i,&j);
        b[i-1][j-1]={0,0};
    }
    k=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            if(b[i][j].F==0&&b[i][j].S==0) continue;
            if(k==3) k=0;
            if(k==0) b[i][j]={0,1};
            else if(k==1) b[i][j]={1,0};
            else if(k==2) b[i][j]={1,1};
            k++;
        }
    while(t--){
        scanf("%d%d",&i,&j);
        i--;j--;
        if(b[i][j].F==0&&b[i][j].S==0) printf("Waste\n");
        else if(b[i][j].F==0&&b[i][j].S==1) printf("Carrots\n");
        else if(b[i][j].F==1&&b[i][j].S==0) printf("Kiwis\n");
        else if(b[i][j].F==1&&b[i][j].S==1) printf("Grapes\n");
    }

    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m=-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sortd(x,y) sort(x,y,greater<int>());
#define F first
#define S second

const int maxn = (i64)1e9+7;
const double pi = acos(-1.0);

//bool fne(const pii &a, const pii &b){return (a.F > b.F)||(a.F==b.F&&a.S>b.S);}
//bool sne(const pii &a, const pii &b){return (a.S < b.S)||(a.S==b.S&&a.F<b.F);}
//bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

int arr[10004];
int main(){
    //read;
    fio;
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    map<pii,bool>mp;
    int a,b;
    arr[1]=0;
    for(int i=2;i<=n;i++) arr[i]=m;
    while(k--){
        cin>>a>>b;
        mp[{a,b}]=1;
        arr[a+1]--;
    }
    for(int i=2;i<=n;i++) arr[i]+=arr[i-1]+1;
    while(t--){
        cin>>a>>b;
        if(mp[{a,b}]) {cout<<"Waste"<<endl;continue;}
        int x=arr[a];
        for(int i=1;i<=b;i++){
            if(mp[{a,i}]) continue;
            x++;
        }
        x%=3;
        if(x==1) cout<<"Carrots";
        else if(x==2) cout<<"Kiwis";
        else if(x==0) cout<<"Grapes";
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int BS(pair<int,int>p[],int n,int a,int b){
	int l=0,r=n-1,mid;
	while(l<r){
		mid = (l+r+1)/2;
		//cout<<l<<" "<<mid<<" "<<r<<endl;
		if(p[mid].first == a&&p[mid].second==b) return -1;
		else if(p[mid].first == a)
			if(p[mid].second<b)l=mid;
			else r=mid-1;
		else if(p[mid].first < a)	l=mid;
		else	r=mid-1;
	}
	if(p[l].first == a&&p[l].second == b)return -1;
	return l+1;
}
int main() {
	int n,m,k,t,a,b,i=0,kk;
	scanf("%d %d %d %d",&n,&m,&k,&t);
	kk=k;
	pair<int,int>p[k];
	while(k--){
		scanf("%d %d",&a,&b);
		p[i++]=make_pair(a,b);
	}
	sort(p,p+n);
	string s="CKG";
	while(t--){
		scanf("%d %d",&a,&b);
		int x = BS(p,kk,a,b);
		int tmp = ((a-1)*m)+b-x;
		if(tmp)tmp--;
		if(x==-1)puts("Waste");
		else if(s[tmp%3]=='C')puts("Carrots");
		else if(s[tmp%3]=='K')puts("Kiwis");
		else puts("Grapes");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int BS(pair<int,int>p[],int n,int a,int b){
	int l=0,r=n-1,mid;
	while(l<r){
		mid = (l+r+1)/2;
		//cout<<l<<" "<<mid<<" "<<r<<endl;
		if(p[mid].first == a&&p[mid].second==b) return -1;
		else if(p[mid].first == a)
			if(p[mid].second<b)l=mid;
			else r=mid-1;
		else if(p[mid].first < a)	l=mid;
		else	r=mid-1;
	}
	if(p[l].first == a&&p[l].second == b)return -1;
	return l+1;
}
int main() {
	int n,m,k,t,a,b,i=0,kk;
	scanf("%d %d %d %d",&n,&m,&k,&t);
	kk=k;
	pair<int,int>p[k];
	while(k--){
		scanf("%d %d",&a,&b);
		p[i++]=make_pair(a,b);
	}
	sort(p,p+k);
	string s="CKG";
	while(t--){
		scanf("%d %d",&a,&b);
		int x = BS(p,kk,a,b);
		int tmp = ((a-1)*m)+b-x;
		if(tmp)tmp--;
		if(x==-1)puts("Waste");
		else if(s[tmp%3]=='C')puts("Carrots");
		else if(s[tmp%3]=='K')puts("Kiwis");
		else puts("Grapes");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int BS(pair<int,int>p[],int n,int a,int b){
	int l=0,r=n-1,mid;
	while(l<r){
		mid = (l+r+1)/2;
		//cout<<l<<" "<<mid<<" "<<r<<endl;
		if(p[mid].first == a&&p[mid].second==b) return -1;
		else if(p[mid].first == a)
			if(p[mid].second<b)l=mid;
			else r=mid-1;
		else if(p[mid].first < a)	l=mid;
		else	r=mid-1;
	}
	if(p[l].first == a)
		if(p[l].second == b)	return -1;
		else if(p[l].second > b) return l;
		else	return l+1;
	else if(p[l].first > a)	return l;
	return l+1;
}
int main() {
	int n,m,k,t,a,b,i=0,kk;
	scanf("%d %d %d %d",&n,&m,&k,&t);
	kk=k;
	pair<int,int>p[k];
	while(k--){
		scanf("%d %d",&a,&b);
		p[i++]=make_pair(a,b);
	}
	sort(p,p+kk);
	string s="CKG";
	while(t--){
		scanf("%d %d",&a,&b);
		int x = BS(p,kk,a,b);
		int tmp = ((a-1)*m)+b-x;
		if(tmp)tmp--;
		if(x==-1)puts("Waste");
		else if(s[tmp%3]=='C')puts("Carrots");
		else if(s[tmp%3]=='K')puts("Kiwis");
		else puts("Grapes");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int BS(pair<int,int>p[],int n,int a,int b){
	int l=0,r=n-1,mid;
	while(l<r){
		mid = (l+r+1)/2;
		//cout<<l<<" "<<mid<<" "<<r<<endl;
		if(p[mid].first == a&&p[mid].second==b) return -1;
		else if(p[mid].first == a)
			if(p[mid].second<b)l=mid;
			else r=mid-1;
		else if(p[mid].first < a)	l=mid;
		else	r=mid-1;
	}
	if(p[l].first == a&&p[l].second == b)return -1;
	return l+1;
}
int main() {
	int n,m,k,t,a,b,i=0,kk;
	scanf("%d %d %d %d",&n,&m,&k,&t);
	kk=k;
	pair<int,int>p[k];
	while(k--){
		scanf("%d %d",&a,&b);
		p[i++]=make_pair(a,b);
	}
	sort(p,p+kk);
	string s="CKG";
	while(t--){
		scanf("%d %d",&a,&b);
		int x = BS(p,kk,a,b);
		int tmp = ((a-1)*m)+b-x;
		if(tmp)tmp--;
		if(x==-1)puts("Waste");
		else if(s[tmp%3]=='C')puts("Carrots");
		else if(s[tmp%3]=='K')puts("Kiwis");
		else puts("Grapes");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,k,t,a,b;
	scanf("%d %d %d %d",&n,&m,&k,&t);
	char mat[n][m]={};
	while(k--){
		scanf("%d %d",&a,&b);
		mat[a-1][b-1]='W';
	}
	string s="CKG";
	int c=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(mat[i][j]!='W')
				mat[i][j]=s[c%3],c++;
	while(t--){
		scanf("%d %d",&a,&b);
		if(mat[a-1][b-1]=='W')puts("Waste");
		else if(mat[a-1][b-1]=='C')puts("Carrots");
		else if(mat[a-1][b-1]=='K')puts("Kiwis");
		else puts("Grapes");
	}
	return 0;
}


#include<iostream>
#include<vector>
#include<string>

using namespace std;

string arr[] = { "Carrots", "Kiwis" , "Grapes" };

int main()
{
	int n, m,k,t;
	cin >> n >> m >> k >>t;
	vector<vector<char>>grid(n);
	for (int i = 0; i < n; ++i) {
		grid[i].resize(m);;
	}
	int first, second;
	for (int i = 0; i < k; ++i) {
		cin >> first >> second;
		grid[first-1][second-1] = 'W';
	}
	int marker = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (grid[i][j] != 'W') {
				grid[i][j] = arr[marker].front();
				marker == 2 ? marker = 0 : ++marker;
			}
		}
	}
	for (int i = 0; i < t; ++i) {
		cin >> first >> second;
		if (grid[first - 1][second - 1] == 'W') {
			cout << "Waste" << '\n';
		}
		else if (grid[first - 1][second - 1] == 'C') {
			cout << "Carrots" << '\n';
		}
		else if (grid[first - 1][second - 1] == 'K') {
			cout << "Kiwis" << '\n';
		}
		else {
			cout << "Grapes" << '\n';
		}

	}
}


#include<iostream>
#include<vector>
#include<string>

using namespace std;

string arr[] = { "Carrots", "Kiwis" , "Grapes" };

int main()
{
	int n, m,k,t;
	cin >> n >> m >> k >>t;
	vector<vector<string>>grid(n);
	for (int i = 0; i < n; ++i) {
		grid[i].resize(m);;
	}
	int first, second;
	for (int i = 0; i < k; ++i) {
		cin >> first >> second;
		grid[first-1][second-1] = "Waste";
	}
	int marker = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (grid[i][j] != "Waste") {
				grid[i][j] = arr[marker];
				marker == 2 ? marker = 0 : ++marker;
			}
		}
	}
	for (int i = 0; i < t; ++i) {
		cin >> first >> second;
		cout << grid[first-1][second-1] << endl;
	}
}


#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int n, m,k,t;
	cin >> n >> m >> k >>t;
	vector <pair<int, int>>grid(k);
	int first, second;
	for (int i = 0; i < k; ++i) {
		cin >> first >> second;
		grid[i] = make_pair(first, second);
	}
	for (int i = 0; i < t; ++i) {
		cin >> first >> second;
		bool found = false;
		int pos = (first - 1) * m + second;
		for (int j = 0; j < k; ++j) {
			if (first > grid[j].first || (first == grid[j].first && second > grid[j].second)) {
				--pos;
			}
			if (grid[j].first == first && grid[j].second == second) {
				cout << "Waste" << endl;
				found = true;
				break;
			}
		}
		if (!found) {
			switch (pos%3) {
			case 0:cout << "Grapes" << endl;
				   break;
			case 1:cout << "Carrots" << endl;
				   break;

			case 2:cout << "Kiwis" << endl;
				   break;
			}
		}
	}

}


#include <iostream>
#include <string.h>
#include<cstring>
#include <vector>
#include <string>
#include <cmath>
#include<stack>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <sstream>
#include <iomanip>
#define fast ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define ll long long
#define fri(x,n)	for(int i = x ; i < n ; i++)
#define frj(x,n)	for(int j = x ; j < n ; j++)
#define inf 1e9
#define MAX 100+9
//int dx[2] = { 0,1 };
//int dy[2] = { 1,0 };
using namespace std;
#define PB push_back
ll GCD(ll a, ll b) { return (a) ? GCD(b % a, a) : b; } // greaest commom divisor
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }     // least common multiplier
double power(double a, ll b) { double x = 1; for (int i = 0; i < b; i++) { x = x * a; } return x; }

int main()
{

	int n, m, k, t;
	cin >> n >> m >> k >> t;

	int* arr = new int[k];
	int pos, i, j;
	for (int i1 = 0; i1 < k; i1++)
	{
		cin >> i >> j;
		pos = m * (i - 1) + j;
		arr[i1] = pos;
	}
	sort(arr, arr + k);

	while (t--)
	{
		cin >> i >> j;
		pos = pos = m * (i - 1) + j;
		int ans = -1;
		int pos2 = 0;
		int l = 0;
		int r = k - 1;
		while (l <= r)
		{
			int mid = (r + l) / 2;
			if (arr[mid] == pos)
			{
				pos2 = 1;
				break;
			}
			else if (arr[mid] < pos)
			{
				ans = mid;
				l = mid + 1;
			}
			else
			{
				r = mid - 1;
			}
		}
		if (pos2 == 1)
		{
			cout << "Waste" << endl;
		}
		else
		{
			if ((pos - (ans + 1)) % 3 == 1)
			{
				cout << "Carrots" << endl;
			}
			else if ((pos - (ans + 1)) % 3 == 2)
			{
				cout << "Kiwis" << endl;
			}
			else
			{
				cout << "Grapes" << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <string.h>
#include<cstring>
#include <vector>
#include <string>
#include <cmath>
#include<stack>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <sstream>
#include <iomanip>
#define fast ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define ll long long
#define fri(x,n)	for(int i = x ; i < n ; i++)
#define frj(x,n)	for(int j = x ; j < n ; j++)
#define inf 1e9
#define MAX 100+9
//int dx[2] = { 0,1 };
//int dy[2] = { 1,0 };
using namespace std;
#define PB push_back
ll GCD(ll a, ll b) { return (a) ? GCD(b % a, a) : b; } // greaest commom divisor
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }     // least common multiplier
double power(double a, ll b) { double x = 1; for (int i = 0; i < b; i++) { x = x * a; } return x; }
vector< char > v(40009 * 40009);

int main()
{

	int n, m, k, t;
	cin >> n >> m >> k >> t;
	int a, b;

	while (k--)
	{
		cin >> a >> b;
		v[(a - 1) * m + b] = 'N';
	}

	int counter = 1;

	fri(1, n + 1)
	{
		frj(1, m + 1)
		{
			if (v[(i - 1) * m + j] == 'N')
				continue;
			if (counter % 3 == 1)
			{
				v[(i - 1) * m + j] = 'C';
			}
			else if (counter % 3 == 2)
			{
				v[(i - 1) * m + j] = 'K';
			}
			else
			{
				v[(i - 1) * m + j] = 'G';
			}
			counter++;
		}
	}

	while (t--)
	{
		cin >> a >> b;
		if (v[(a - 1) * m + b] == 'N')
			cout << "Waste" << endl;
		else if (v[(a - 1) * m + b] == 'C')
			cout << "Carrots" << endl;
		else if (v[(a - 1) * m + b] == 'K')
			cout << "Kiwis" << endl;
		else if (v[(a - 1) * m + b] == 'G')
			cout << "Grapes" << endl;
	}

	return 0;
}


#include <iostream>
#include <string.h>
#include<cstring>
#include <vector>
#include <string>
#include <cmath>
#include<stack>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <sstream>
#include <iomanip>
#define fast ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define ll long long
#define fri(x,n)	for(int i = x ; i < n ; i++)
#define frj(x,n)	for(int j = x ; j < n ; j++)
#define inf 1e9
#define MAX 100+9
//int dx[2] = { 0,1 };
//int dy[2] = { 1,0 };
using namespace std;
#define PB push_back
ll GCD(ll a, ll b) { return (a) ? GCD(b % a, a) : b; } // greaest commom divisor
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }     // least common multiplier
double power(double a, ll b) { double x = 1; for (int i = 0; i < b; i++) { x = x * a; } return x; }

char graphe[40000 + 9][40000 + 9];

int main()
{
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	int a, b;

	while (k--)
	{
		cin >> a >> b;
		graphe[a][b] = 'N';
	}

	int counter = 1;

	fri(1, n + 1)
	{
		frj(1, m + 1)
		{
			if (graphe[i][j] == 'N')
				continue;
			if (counter % 3 == 1)
			{
				graphe[i][j] = 'C';
			}
			else if (counter % 3 == 2)
			{
				graphe[i][j] = 'K';
			}
			else
			{
				graphe[i][j] = 'G';
			}
			counter++;
		}
	}

	while (t--)
	{
		cin >> a >> b;
		if (graphe[a][b] == 'N')
			cout << "Waste" << endl;
		else if (graphe[a][b] == 'C')
			cout << "Carrots" << endl;
		else if (graphe[a][b] == 'K')
			cout << "Kiwis" << endl;
		else if (graphe[a][b] == 'G')
			cout << "Grapes" << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
#include<cctype>
#include<deque>
#include<iomanip>
#define endl "\n"

#define ll  long long
using namespace std;

int main() {
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	vector<int>field;
	int r, c;
	for (int i = 0;i < k;i++) {
		cin >> r >> c;
		field.push_back((r - 1) * m + (c-1));

	}
	sort(field.begin(), field.end());
	for (int j = 0;j < t;j++) {
		cin >> r >> c;
		int v = (r - 1) * m + (c-1);
		auto it = upper_bound(field.begin(), field.end(), v);
		if (it == field.begin()) {
			if (v % 3 == 0) {
				cout << "Carrots" << endl;
			}
			else if (v % 3 == 1) {
				cout << "Kiwis" << endl;
			}
			else {
				cout << "Grapes" << endl;
			}
		}
		else {
			it--;

			if (v == *it) {
				cout << "Waste" << endl;
			}
			else {
				int dist = distance(field.begin(), it)-1;
				v += dist;
				if (v % 3 == 0) {
					cout << "Carrots" << endl;
				}
				else if (v % 3 == 1) {
					cout << "Kiwis" << endl;
				}
				else {
					cout << "Grapes" << endl;
				}
			}
		}

	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
#include<cctype>
#include<deque>
#include<iomanip>
#define endl "\n"

#define ll  long long
using namespace std;

int main() {
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	vector<int>field;
	int r, c;
	for (int i = 0;i < k;i++) {
		cin >> r >> c;
		field.push_back((r - 1) * m + (c-1));

	}
	sort(field.begin(), field.end());
	for (int j = 0;j < t;j++) {
		cin >> r >> c;
		int v = (r - 1) * m + (c-1);
		auto it = upper_bound(field.begin(), field.end(), v);
		if (it == field.begin()) {
			if (v % 3 == 0) {
				cout << "Carrots" << endl;
			}
			else if (v % 3 == 1) {
				cout << "Kiwis" << endl;
			}
			else {
				cout << "Grapes" << endl;
			}
		}
		else {
			it--;

			if (v == *it) {
				cout << "Waste" << endl;
			}
			else {
				int dist = distance(field.begin(), it)+1;
				v -= dist;
				if (v % 3 == 0) {
					cout << "Carrots" << endl;
				}
				else if (v % 3 == 1) {
					cout << "Kiwis" << endl;
				}
				else {
					cout << "Grapes" << endl;
				}
			}
		}

	}
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	   cin >> a[i];
	}
	if (k >= n) {
		cout << n;
	} else {
	 	int cnt = 0, f = a[0];
	 	vector <int> g(a, a + n);
	 	g.erase(g.begin());
	 //	for (int i : g) cout << i << ' ';
	 	cout << '\n';
		while (1) {
		 	if (f > g[0]) {
		 	 	g.PB(g[0]);
		 	 	g.erase(g.begin());
		 	 	cnt ++;
		 	} else {
		 	 	g.PB(f);
		 	 	if (cnt >= k) {
		 	 	 	cout << f;
		 	 	 	return;
		 	 	}
		 	 	f = g[0];
		 	 	g.erase(g.begin());
		 	 	cnt = 1;
		 	}
		 	if (cnt >= k) {
		 	    cout << f;
		 	    return;
		 	}

		}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	   cin >> a[i];
	}
	if (k >= n) {
		cout << n;
	} else {
	 	int cnt = 0, f = a[0];
	 	vector <int> g(a, a + n);
	 	g.erase(g.begin());
		while (1) {
		 	if (f > g[0]) {
		 	 	g.PB(g[0]);
		 	 	g.erase(g.begin());
		 	 	cnt ++;
		 	} else {
		 	 	g.PB(f);
		 	 	if (cnt <= k) {
		 	 	 	cout << f;
		 	 	 	return;
		 	 	}
		 	 	f = g[0];
		 	 	cnt = 1;
		 	}
		 	if (cnt <= k) {
		 	    cout << f;
		 	    return;
		 	}

		}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

// 87077969797 goat

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	 	cin >> a[i];
	}
	if (k > n - 1) {
	 	sort(a, a + n);
	 	cout << a[n - 1];
	 	return;
	}
	for (int i = 0; i < n; i ++) {
	    int cnt = 0;
	    for (int j = i; j < n; j ++) {
	     	if (a[i] < a[j]) break;
	     	cnt ++;
	    }
	    if (cnt >= k) {cout << a[i]; break;}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	   cin >> a[i];
	}
	if (k >= n) {
		cout << n;
	} else {
	 	int cnt = 0, f = a[0];
	 	vector <int> g(a, a + n);
	 	g.erase(g.begin());
	 	for (int i : g) cout << i << ' ';
	 	cout << '\n';
		while (1) {
		 	if (f > g[0]) {
		 	 	g.PB(g[0]);
		 	 	g.erase(g.begin());
		 	 	cnt ++;
		 	} else {
		 	 	g.PB(f);
		 	 	if (cnt >= k) {
		 	 	 	cout << f;
		 	 	 	return;
		 	 	}
		 	 	f = g[0];
		 	 	g.erase(g.begin());
		 	 	cnt = 1;
		 	}
		 	if (cnt >= k) {
		 	    cout << f;
		 	    return;
		 	}

		}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	   cin >> a[i];
	}
	if (k >= n) {
		cout << n;
	} else {
	 	int cnt = 0, f = a[0];
	 	vector <int> g(a, a + n);
	 	g.erase(g.begin());
		while (1) {
		 	if (f > g[0]) {
		 	 	g.PB(g[0]);
		 	 	g.erase(g.begin());
		 	 	cnt ++;
		 	} else {
		 	 	g.PB(f);
		 	 	if (cnt <= k) {
		 	 	 	cout << f;
		 	 	 	return;
		 	 	}
		 	 	f = g[0];
		 	 	cnt = 0;
		 	}
		 	if (cnt <= k) {
		 	    cout << f;
		 	    return;
		 	}

		}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;

#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(l,r,c) for(int c=(l);c<=(r);c++)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

// 87077969797 goat

using ll = long long;
#define int ll

const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

void solve()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; i ++) {
	 	cin >> a[i];
	}
	if (k > n - 1) {
	 	sort(a, a + n);
	 	cout << a[n - 1];
	 	return;
	}
	for (int i = 0; i < n; i ++) {
	    int cnt = 0;
	    for (int j = i; j < n; j ++) {
	     	if (a[i] <= a[j]) break;
	     	cnt ++;
	    }
	    if (cnt >= k) {cout << a[i]; break;}
	}
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,m;
    long long int k,maxi=0;
    cin>>n>>k;
    long long int a[2*n],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        maxi=max(maxi,a[i]);
        a[n+i]=a[i];
    }
    for(i=0;i<(2*n);i++)
    {
        set<long long int>s;
        if(a[i-1]<a[i])
        {
            s.insert(a[i-1]);
        }
        for(m=i+1;m<(2*n);m++)
        {
            if(a[i]>a[m])
            {
                s.insert(a[m]);
            }
            else
            {
                break;
            }
        }
        if(i<n)
        {
            c[i]=s.size();
        }
    }
   for(i=0;i<n;i++)
   {
       if(c[i]>=k)
       {
           cout<<a[i]<<endl;
           return 0;
       }
   }
   cout<<maxi<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,maxi=0;
    long long int k;
    cin>>n>>k;
    int a[(2*n)+1],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=maxi)
        {
            maxi=a[i];
        }
        a[n+i]=a[i];
    }
    for(i=0;i<((2*n)-1);i++)
    {
        int cnt=0;
        for(j=i+1;j<((2*n)-1);j++)
        {
            if(a[i]>a[j])
            {
              cnt++;
            }
            else
            {
                break;
            }
        }
        if(i<n)
        {
            c[i]=cnt;
        }
        cnt=0;
    }
    for(i=0;i<n;i++)
    {
        if(c[i]>=k)
        {
            cout<<a[i]<<endl;
            return 0;
        }
    }
    cout<<maxi<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,m;
    long long int k,maxi=0;
    cin>>n>>k;
    long long int a[2*n],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        maxi=max(maxi,a[i]);
        a[n+i]=a[i];
    }
    for(i=0;i<(2*n);i++)
    {
        set<long long int>s;
        for(j=i-1;j>=0;j--)
        {
            if(a[i]>a[j])
            {
                s.insert(a[j]);
            }
            else
            {
                break;
            }
        }
        for(m=i+1;m<(2*n);m++)
        {
            if(a[i]>a[m])
            {
                s.insert(a[m]);
            }
            else
            {
                break;
            }
        }
        if(i<n)
        {
            c[i]=s.size();
        }
    }
   for(i=0;i<n;i++)
   {
       if(c[i]>=k)
       {
           cout<<a[i]<<endl;
           return 0;
       }
   }
   cout<<maxi<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,maxi=501;
    long long int k;
    cin>>n>>k;
   vector<int>a(n),b(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a.rbegin(),a.rend());
    for(i=0;i<n;i++)
    {
        if((n-(i+1))>=k)
        {
            for(j=0;j<n;j++)
            {
                if(a[i]==b[j])
                {
                    maxi=min(maxi,j);
                }
            }
        }
    }
    if(maxi<501)
    {
        cout<<b[maxi]<<endl;
    }
    else
    {
        cout<<a[0]<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<long long int>v;
int main()
{
    long long int  n, i, j, k, p, q, x, y;
    cin>>n>>k;
    for(i = 0; i < n; i++)
    {
        cin>>p;
        v.push_back(p);
    }
    i = j = 0;
    while(j < min(n, k))
    {
        if(v[i] > v[i+1])
        {
            swap(v[i], v[i+1]);
            v.push_back(v[i]);
            j++;
        }
        else
        {
            v.push_back(v[i]);
            j = 1;
        }
            i++;
    }
        cout<<v[i]<<endl;
        return 0;
    }


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n-1) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if (now > f || now > b) here++;
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n-1) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if (now == v2[1] && v[1] > v[0]) here++;
    else if (now == v2[0] && v[0] > v[1]) here++;
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n-1) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if ((now > f || now > b) && now != f && now != b) here++;
    else if (now == max (b,f) && here > 1) here++;
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if (now == v2[1] && v[1] > v[0]) here++;
    else if (now == v2[0] && v[0] > v[1]) here++;
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


/************************************ PALESTINE *****************************************
 Suhaib     ________   |     |   |     |        /\      _______    _______   صهيب صوالحه
            |          |     |   |     |       /  \        |       |     |
            |_______   |     |   |_____|      /____\       |       |_____)
                    |  |     |   |     |     /      \      |       |     )
            ________|  \_____/   |     |    /        \   __|___    |_____|   Sawalha
************************************* PALESTINE ****************************************/

#include <bits/stdc++.h>
//#include "TheReality.h"
//#include "People.h"

using namespace std;

#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;

typedef long long ll;

#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define out(n) cout << n << endl

#define loop(i,k,n) for (int i = k ; i < n ; ++i)
#define for_auto(v) for (auto z : v)
#define for_it(it,v) for (it = v.begin();it != v.end();++it)
#define co_co(v) copy(v.begin(),v.end(),ostream_iterator<ll>(cout , " "))
#define for_cin(v) for(auto &x:v) cin >> x;
#define sor(v) sort (v.begin(),v.end())
#define sorv(v) sort (v.rbegin(),v.rend())
#define rev(v) reverse (v.begin(),v.end())
#define wh(n) while (n--)
#define debug(n) cout << '[' << #n << " = " << n << "]" << endl;

void Suhaib_Sawalha (){

ll n , k;
cin >> n >> k;
vector <ll> v (n) , v2;
for_cin(v);
v2 = v;
ll f = v[0] , b = v[1];
if (k >= n-1) {out(*max_element(v2.begin(),v2.end())); return;}
while (!v.empty()){
    ll now = v.front() , here (-1);
    v.erase(v.begin());
    vector <ll> :: iterator it = v.begin();
    while (it != v.end()){
    if (*it > now) {here = it-v.begin(); break;}
    it++;
    }
    if (here == -1) here = v.size();
    if ((now > f || now > b) && now != f && now != b) here++;
    else if (now == max (b,f) && (here > 1 || now == b)) here++;
    if (here >= k && now >= f && now >= b){out(now); return;}
}
out(*max_element(v2.begin(),v2.end()));
}

void Suhaib_Sawalha1 (){
ll t;
cin >> t;
wh(t) {Suhaib_Sawalha();}
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
Suhaib_Sawalha ();
                                         Alhamdulillah                    /* الحمد لله */
}


//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,a[505]={},j,now;
  cin >> n >> k;
  if(k>=n-1) {
    cout << n << endl;
    return 0;
  }
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  now=a[0];
  for(int i=0; i<n; i++) {
    j=0;
    while(now>a[i]) {
      j++;
      if(j==k) {
        cout << now << endl;
        return 0;
      }
    }
    now=a[i];
  }
}


//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,x,a[505]={},ans;
  cin >> n >> k;
  cin >> x;
  ans=x;
  for(int i=1; i<n; i++) {
    cin >> x;
    if(ans<x) {
      ans=x;
      a[ans]++;
    }
    else {
      a[ans]++;
    }
    if(a[ans]==k) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << n << endl;
}


//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,a[505]={},j,now;
  cin >> n >> k;
  if(k>=n-1) {
    cout << n << endl;
    return 0;
  }
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  now=a[0];
  for(int i=1; i<n; i++) {
    j=0;
    while(now>a[i]) {
      j++;
      i++;
      if(j==k) {
        cout << now << endl;
        return 0;
      }
    }
    now=a[i];
  }
  cout << n << endl;
}


//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,x,a[505]={},ans;
  cin >> n >> k;
  cin >> x;
  ans=x;
  for(int i=1; i<n; i++) {
    cin >> x;
    if(ans<x) {
      ans=x;
      a[ans]++;
    }
    else {
      a[ans]++;
    }
    if(a[ans]==k) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << n << endl;
}


//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,a[505]={},j,now;
  cin >> n >> k;
  if(k>=n-1) {
    cout << n << endl;
    return 0;
  }
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  now=a[0];
  for(int i=1; i<n; i++) {
    if(a[0]>a[1]) {
      j=0;
    }
    else {
      j=1;
    }
    while(now>a[i]) {
      j++;
      i++;
      if(j==k) {
        cout << now << endl;
        return 0;
      }
    }
    now=a[i];
  }
  cout << n << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

bool cmp(pii a, pii b)
{
	if (a.ff == b.ff)
		return a.ss > b.ss;
	return a.ff < b.ff;
}
int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

vi digits(int n)
{
	vi nonzerodigits;
	int dig;
	while (n > 0)
	{
		dig = n % 10;
		if (dig != 0)
			nonzerodigits.pb(dig);
		n /= 10;

	}
	reverse(nonzerodigits.begin(), nonzerodigits.end());
	return nonzerodigits;
}

int32_t main()
{
	// FIO;
	c_p_c();
	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int max_index = max_element(arr, arr + n) - arr + 1;
	if (max_index <= k )
		cout << arr[max_index - 1] << endl;
	else
	{
		max_index  = max_element(arr, arr + k) - arr + 1;
		cout << arr[max_index - 1] << endl;
	}
}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

void print(vi j)
{
	for (int i = 0; i < j.size(); i++)
	{
		cout << j[i] << " ";
	}
	cout << endl;
}

// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------

int32_t main()
{
	// FIO;
	c_p_c();
//--------------------------------------------------

	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i] == n)
			max = i;
	}

	bool flag = false;
	int i;
	for (i = 0; i < max; i++)
	{
		int wins = 0 ;
		int j = i + 1;
		while (1)
		{
			if (arr[i] > arr[j] )
				wins++;
			else
				break;
			j++;

		}
		if (wins >= k)
		{
			flag = true;
			break;
		}
	}

	if (flag)
	{
		cout << arr[i] << endl;

	}
	else
		cout << n << endl;

}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

void print(vi j)
{
	for (int i = 0; i < j.size(); i++)
	{
		cout << j[i] << " ";
	}
	cout << endl;
}

// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------

int32_t main()
{
	// FIO;
	c_p_c();
//--------------------------------------------------

	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i] == n)
			max = i;
	}

	bool flag = false;
	int i;
	for (i = 0; i < max; i++)
	{
		int wins = 0 ;
		int j = i + 1;
		if (i == 1 && arr[0] < arr[1])
			wins++;
		while (1)
		{
			if (arr[i] > arr[j] )
				wins++;
			else
				break;
			j++;

		}
		if (wins >= k)
		{
			flag = true;
			break;
		}
	}

	if (flag)
	{
		cout << arr[i] << endl;

	}
	else
		cout << n << endl;

}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

void print(vi j)
{
	for (int i = 0; i < j.size(); i++)
	{
		cout << j[i] << " ";
	}
	cout << endl;
}

// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------

int32_t main()
{
	// FIO;
	c_p_c();
//--------------------------------------------------

	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i] == n)
			max = i;
	}

	bool flag = false;
	int i;
	for (i = 0; i < max; i++)
	{
		int wins = 0 ;
		int j = i + 1;
		if (i >= 1 && arr[i - 1] < arr[i])
			wins++;
		while (1)
		{
			if (arr[i] > arr[j] )
				wins++;
			else
				break;
			j++;

		}
		if (wins >= k)
		{
			flag = true;
			break;
		}
	}

	if (flag)
	{
		cout << arr[i] << endl;

	}
	else
		cout << n << endl;

}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

void print(vi j)
{
	for (int i = 0; i < j.size(); i++)
	{
		cout << j[i] << " ";
	}
	cout << endl;
}

// int power(int x, unsigned int y, int p)
// {
// 	int res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }
// Graph------------------------------------------------------------------------

int32_t main()
{
	// FIO;
	c_p_c();
//--------------------------------------------------

	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i] == n)
			max = i;
	}

	bool flag = false;
	int i;
	for (i = 0; i < max; i++)
	{
		int wins = 0 ;
		int j = i + 1;
		while (1)
		{
			if (arr[i] > arr[j] )
				wins++;
			else
				break;
			j++;

		}
		if (wins == k)
		{
			flag = true;
			break;
		}
	}

	if (flag)
	{
		cout << arr[i] << endl;

	}
	else
		cout << n << endl;

}


#include<bits/stdc++.h>

using namespace std;

#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vi primes;
	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}

bool cmp(pii a, pii b)
{
	if (a.ff == b.ff)
		return a.ss > b.ss;
	return a.ff < b.ff;
}
int lengthOfLongestIncreasingSubsequence(int arr[], int n)
{
	int max = 1, len = 1;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] > arr[i - 1])
			len++;
		else
		{
			if (max < len)
				max = len;

			len = 1;
		}
	}
	if (max < len)
		max = len;

	return max;
}

set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

vi digits(int n)
{
	vi nonzerodigits;
	int dig;
	while (n > 0)
	{
		dig = n % 10;
		if (dig != 0)
			nonzerodigits.pb(dig);
		n /= 10;

	}
	reverse(nonzerodigits.begin(), nonzerodigits.end());
	return nonzerodigits;
}

int32_t main()
{
	// FIO;
	c_p_c();
	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int max_index = max_element(arr, arr + n) - arr + 1;
	if (max_index <= k )
		cout << arr[max_index - 1] << endl;
	else
	{
		max_index = max_element(arr, arr + max_index - k) - arr;
		cout << arr[max_index] << endl;
	}
}


#include <iostream>
#include<vector>
#include <cmath>
#include <queue>

using namespace std;

int main(){
int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;

        int cur_winner=v[0];
        int compare;
        for(int i=1;i<n;i++) q.push(v[i]);
        while(temp>=0 && q.empty()==false){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
                temp--;
            }

            else{
                temp=k-1;
                q.push(cur_winner);
                cur_winner = compare;
            }
        }
        cout << cur_winner;
    }

}


#include <iostream>
#include<vector>
#include <cmath>
#include <queue>

using namespace std;

int main(){
int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;
        int cur_winner = max(v[0],v[1]);
        if (v[1]>v[0]) q.push(v[0]);
        else q.push(v[1]);
        for(int i=2;i<n;i++) q.push(v[i]);
        temp--;
        int compare;
        while(temp>0){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
            }
            else{
                temp=k;
                q.push(cur_winner);
                cur_winner = compare;
            }
            temp--;
        }
        cout << cur_winner;
    }

}


#include <iostream>
#include<vector>
#include <cmath>
#include <queue>

using namespace std;

int main(){
int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;

        int cur_winner=v[0];
        int compare;
        for(int i=1;i<n;i++) q.push(v[i]);
        while(temp>=0 && q.empty()==false){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
                temp--;
            }

            else{
                temp=k-1;
                q.push(cur_winner);
                cur_winner = compare;
            }
            if(temp==0) break;
        }
        cout << cur_winner;

    }

}


#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;
        int cur_winner = max(v[0],v[1]);
        if (v[1]>v[0]) q.push(v[0]);
        else q.push(v[1]);
        for(int i=2;i<n;i++) q.push(v[i]);
        temp--;
        int compare;
        while(temp>0){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
            }
            else{
                temp=k;
                q.push(cur_winner);
                cur_winner = compare;
            }
            temp--;
        }
        cout << cur_winner;
    }

}


#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;
        int cur_winner = max(v[0],v[1]);
        if (v[1]>v[0]) q.push(v[0]);
        else q.push(v[1]);
        temp--;
        int compare;
        while(temp>0){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
                temp--;

            }
            else{
                temp=k-1;
                q.push(cur_winner);
                cur_winner = compare;
            }
            temp--;
        }
        cout << cur_winner;
    }

}


#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;
        int cur_winner = max(v[0],v[1]);
        if (v[1]>v[0]) q.push(v[0]);
        else q.push(v[1]);
        for(int i=2;i<n;i++) q.push(v[i]);
        temp--;
        int compare;
        while(temp>=0){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
            }
            else{
                temp=k;
                q.push(cur_winner);
                cur_winner = compare;
            }
            temp--;
        }
        cout << cur_winner;
    }

}


#include <iostream>
#include<vector>
#include <cmath>
#include <queue>

using namespace std;

int main(){
int n;
    long long k;
    cin>>n>>k;
    vector <int> v;
    queue <int> q;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    if(n<k){
        cout << n<<endl;
        return 0;
    }
    else{
        int temp=k;

        int cur_winner=v[0];
        int compare;
        for(int i=2;i<n;i++) q.push(v[i]);
        while(temp>=0 && q.empty()==false){
            compare = q.front();
            q.pop();
            if(cur_winner>compare){
                q.push(compare);
                temp--;
            }

            else{
                temp=k-1;
                q.push(cur_winner);
                cur_winner = compare;
            }
            if(temp==0) break;

        }
        cout << cur_winner;
    }

}