#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000);
	ll d = (ll)(D*10000);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll d2 = ((ll)i*d) % (4LL*a);
		ll x, y;
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else{	// if ( d2 >= 3*a && d < 4*a )
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.9lf %.9lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.B";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	ios_base::sync_with_stdio(0);
	double A, D; cin >> A >> D;
	ll a = (ll)(A*10000LL);
	ll d = (ll)(D*10000LL);

//	cerr << "a: " << a << " d: " << d << endl;
	int n; cin >> n;
	for (int i = 1; i <= n; i++ ){
		ll x = 0LL, y = 0LL;
		ll d2 = ((ll)i*d) % (4LL*a);
		if (d2 >= 0LL && d2 < a ){
			x = d2; y = 0LL;
		}else
		if (d2 >= a && d2 < 2LL*a ){
			x = a, y = d2-a;
		}else
		if (d2 >= 2LL*a && d2 < 3LL*a ){
			x = 3LL*a - d2, y = a;
		}else
		if ( d2 >= 3LL*a && d < 4LL*a ){
			x = 0LL, y = 4LL*a - d2;
		} // end if
		printf ("%.10lf %.10lf\n", (double)x/10000., (double)y/10000. );
	} // end for

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

#define exp 1e-5

int main()
{
    double a, d;
    int n;
    scanf("%lf%lf%d",&a,&d,&n);
    d-=4*a*(int)(d/(4*a));
    double x=0, y=0;
    double now;
    for(int i=1; i<=n; i++)
    {
        now = i*d;
        now-=4*a*(int)(now/(4*a));
        if(now>3*a)
        {
            x=0;
            y=4*a-now;
        }
        else
        if(now>2*a)
        {
            y=a;
            x=3*a-now;
        }
        else
        if(now>a)
        {
            x=a;
            y=now-a;
        }
        else
        {
            x=now;
            y=0;
        }
        printf("%.10lf %.10lf\n",x,y);
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

#define exp 1e-5

int main()
{
    double a, d;
    int n;
    scanf("%lf%lf%d",&a,&d,&n);
    d-=4*a*(int)(d/(4*a));
    double x=0, y=0;
    double now;
    for(int i=1; i<=n; i++)
    {
        now = i*d;
        now-=4*a*(int)(now/(4*a));
        if(now>3*a)
        {
            x=0;
            y=now-3*a;
        }
        else
        if(now>2*a)
        {
            y=a;
            x=now-2*a;
        }
        else
        if(now>a)
        {
            x=a;
            y=now-a;
        }
        else
        {
            x=now;
            y=0;
        }
        printf("%.10lf %.10lf\n",x,y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5
#define Maxsize 1005

double sx[Maxsize];
double sy[Maxsize];

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
//    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
//    {
scanf("%lf%lf%d",&a,&d,&n);
        int e=n;
        double x=0, y=0;
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(x>=4*a)
                x-=4*a;
                if(x<=-4*a)
                x+=4*a;
                if(y>=4*a)
                y-=4*a;
                if(y<=-4*a)
                y+=4*a;
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            if(isequal(x,0)&&isequal(y,0))
            {
              e=i;
              break;
            }
            sx[i]=x;
            sy[i]=y;//            printf("%d\n",flag);
        }
        int j=1;
        for(int i=1; i<=n; i++)
        {
            printf("%.10lf %.10lf\n",sx[j],sy[j]);
            j++;
            if(j>e)
            j=1;

        }
//    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
    {
        double x=0, y=0;
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            printf("%.10lf %.10lf\n",x,y);
//            printf("%d\n",flag);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5
#define Maxsize 100500

double sx[Maxsize];
double sy[Maxsize];

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
//    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
//    {
scanf("%lf%lf%d",&a,&d,&n);
        if(d>=4*a)
        d-=4*a;
        int e=n+1;
        double x=0, y=0;
        int flag=0;
        sx[0]=0;
        sy[0]=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(x>=4*a)
                x-=4*a;
                if(x<=-4*a)
                x+=4*a;
                if(y>=4*a)
                y-=4*a;
                if(y<=-4*a)
                y+=4*a;
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            if(isequal(x,0)&&isequal(y,0))
            {
              e=i;
              break;
            }
            sx[i]=x;
            sy[i]=y;//            printf("%d\n",flag);
        }
        int j=1;
        for(int i=1; i<=n; i++)
        {
            printf("%.10lf %.10lf\n",sx[j],sy[j]);
            j++;
            if(j==e)
            j=0;

        }
//    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5
#define Maxsize 100500

double sx[Maxsize];
double sy[Maxsize];

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
//    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
//    {
scanf("%lf%lf%d",&a,&d,&n);
        int e=n;
        double x=0, y=0;
        int flag=0;
        sx[0]=0;
        sy[0]=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(x>=4*a)
                x-=4*a;
                if(x<=-4*a)
                x+=4*a;
                if(y>=4*a)
                y-=4*a;
                if(y<=-4*a)
                y+=4*a;
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            if(isequal(x,0)&&isequal(y,0))
            {
              e=i;
              break;
            }
            sx[i]=x;
            sy[i]=y;//            printf("%d\n",flag);
        }
        int j=1;
        for(int i=1; i<=n; i++)
        {
            printf("%.10lf %.10lf\n",sx[j],sy[j]);
            j++;
            if(j==e)
            j=0;

        }
//    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
    {
        double x=0, y=0;
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(x>=4*a)
                x-=4*a;
                if(x<=-4*a)
                x+=4*a;
                if(y>=4*a)
                y-=4*a;
                if(y<=-4*a)
                y+=4*a;
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            printf("%.10lf %.10lf\n",x,y);
//            printf("%d\n",flag);
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5
#define Maxsize 100500

double sx[Maxsize];
double sy[Maxsize];

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
//    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
//    {
scanf("%lf%lf%d",&a,&d,&n);
        int e=n+1;
        double x=0, y=0;
        int flag=0;
        sx[0]=0;
        sy[0]=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(x>=4*a)
                x-=4*a;
                if(x<=-4*a)
                x+=4*a;
                if(y>=4*a)
                y-=4*a;
                if(y<=-4*a)
                y+=4*a;
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            if(isequal(x,0)&&isequal(y,0))
            {
              e=i;
              break;
            }
            sx[i]=x;
            sy[i]=y;//            printf("%d\n",flag);
        }
        int j=1;
        for(int i=1; i<=n; i++)
        {
            printf("%.10lf %.10lf\n",sx[j],sy[j]);
            j++;
            if(j==e)
            j=0;

        }
//    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define exp 1e-5

bool isequal(double a, double b)
{
   double temp = a-b;
   if(temp<=exp&&temp>=-exp)
   return true;
   return false;
}

int main()
{
    double a, d;
    int n;
    while(scanf("%lf%lf%d",&a,&d,&n)!=EOF)
    {
        double x=0, y=0;
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            if(flag==0)
            {
               x+=d;
            }
            else
            if(flag==1)
            {
               y+=d;
            }
            else
            if(flag==2)
            {
                x-=d;
            }
            else
            y-=d;
            while(!(((isequal(x,0)||isequal(x,a))&&y+exp>=0&&y-exp<=a)||(((isequal(y,0)||isequal(y,a))&&x+exp>=0&&x-exp<=a))))
            {
                if(flag==0)
                {
                    y = x-a;
                    x = a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==1)
                {
                    x-=y-a;
                    y=a;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==2)
                {
                    y+=x;
                    x=0;
                    flag++;
                    flag%=4;
                }
                else
                if(flag==3)
                {
                   x-=y;
                   y=0;
                   flag++;
                   flag%=4;
                }
            }
            printf("%.10lf %.10lf\n",x,y);
            printf("%d\n",flag);
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p - 10e-4;
        double dis=0.0000000000000;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=(float)r;
        }
        else if(side==1){
            x=a;
            y=(float)r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        //if(counter<=44498)
        printf("%.10lf %.10lf\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        long double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        double r=fabs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        printf("%.4lf %.4lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,yc=0,xc=0;
    scanf("%Lf %Lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        long double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        long double r=fabs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=a-r;
        }
        else if(side==3){
            y=a-r;
            x=0;
        }
        printf("%.4Lf %.4Lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p;
        double dis=0;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        if(side==0){
            y=0;
            x=(float)r;
        }
        else if(side==1){
            x=a;
            y=(float)r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        //if(counter<=44498)
        printf("%.10lf %.10lf\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    float a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,yc=0,xc=0;
    scanf("%f %f %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        float dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        float r=fabs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=a-r;
        }
        else if(side==3){
            y=a-r;
            x=0;
        }
        printf("%.4f %.4f\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p;
        double dis=0;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        if(side==0){
            y=0;
            x=(float)r;
        }
        else if(side==1){
            x=a;
            y=(float)r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        if(counter<=44498)
        printf("%.3lf %.3lf\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double x=0,y=0,p,s=0,cov=0;
    double a,d;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    for(int b=1;b<=bottles;b++)
    {
        cov=b*d;
        s=(cov/p - (unsigned long long int)(cov/p)) * p;
        double dis=0;
        dis = floor(s/a)*a;
        int side=(int)(s/a);
        double r=abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(a-r);
        }
        else if(side==3){
            y=(a-r);
            x=0;
        }
        printf("%.10lf %.10lf\n",x,y,b);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double x=0,y=0,p,s=0,cov=0;
    double a,d;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    for(int b=1;b<=bottles;b++)
    {
        cov=b*d;
        s=(cov/p - (int)(cov/p)) * p;
        double dis=0;
        dis = floor(s/a)*a;
        int side=(int)(s/a);
        double r=abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(a-r);
        }
        else if(side==3){
            y=(a-r);
            x=0;
        }
        printf("%.10lf %.10lf\n",x,y,b);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double x=0,y=0,p,s=0,cov=0;
    double a,d;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    for(int b=1;b<=bottles;b++)
    {
        cov=b*d;
        s=(cov/p - (int)(cov/p)) * p;
        double dis=0;
        dis=floor(s/a)*a;
        int side=(int)s/a;
        double r=abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(a-r);
        }
        else if(side==3){
            y=(a-r);
            x=0;
        }
        printf("%.10lf %.10lf %d\n",x,y,b);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,yc=0,xc=0;
    scanf("%Lf %Lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        long double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        long double r=fabs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=a-r;
        }
        else if(side==3){
            y=a-r;
            x=0;
        }
        printf("%.10Lf %.10Lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double x=0,y=0,p,s=0,cov=0;
    double a,d;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    for(int b=1;b<=bottles;b++)
    {
        cov=b*d;
        s=(cov/p - (int)(cov/p)) * p;
        double dis=0;
        dis=floor(s/a)*a;
        int side=(int)s/a;
        double r=abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(a-r);
        }
        else if(side==3){
            y=(a-r);
            x=0;
        }
        printf("%.10lf %.10lf\n",x,y,b);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p;
        double dis=0;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        printf("%.4lf %.4lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double x=0,y=0,p,s=0,cov=0;
    double a,d;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    for(int b=1;b<=bottles;b++)
    {
        cov=b*d;
        s=(cov/p - (int)(cov/p)) * p;
        double dis=0.0000000000000000000;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        //if(counter<=44498)
        //printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(a-r);
        }
        else if(side==3){
            y=(a-r);
            x=0;
        }
        //if(counter<=44498)
        printf("%.10lf %.10lf\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p - 10e-4;
        double dis=0.0000000000000;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        if(counter<=44498)
        printf("%lf - %lf = %lf\n",dis,s,r);
        if(side==0){
            y=0;
            x=(float)r;
        }
        else if(side==1){
            x=a;
            y=(float)r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        if(counter<=44498)
        printf("%.10lf %.10lf\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=(cov/p - (int)(cov/p) ) * p;
        double dis=0;
        int side=0;
        while(dis<=s-a){
            dis+=a;
            side++;
        }
        double r = abs(dis-s);
        if(side==0){
            y=0;
            x=(float)r;
        }
        else if(side==1){
            x=a;
            y=(float)r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        if(counter<=44498)
        printf("%.3lf %.3lf %d\n",x,y,counter+=2);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,yc=0,xc=0;
    scanf("%Lf %Lf %d",&a,&d,&bottles);
    cout << a << endl << d << endl << bottles << endl;
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        long double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        long double r=fabs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=a-r;
        }
        else if(side==3){
            y=a-r;
            x=0;
        }
        printf("%.10Lf %.10Lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,counter=1;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        long double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        double r=abs(dis-s);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=(float)(a-r);
        }
        else if(side==3){
            y=(float)(a-r);
            x=0;
        }
        printf("%.4lf %.4lf\n",x,y);
    }
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <bitset>
#include <cstring>
using namespace std;
main()
{
    double a,d,x=0,y=0,p,s=0,cov=0;
    int bottles,flag=0,yc=0,xc=0;
    scanf("%lf %lf %d",&a,&d,&bottles);
    p=4*a;
    while(bottles--)
    {
        cov+=d;
        s=cov;
        while(s>p)
            s-=p;
        int side=0;
        double dis=0;
        while(dis<s-a)
        {
            dis+=a;
            side++;
        }
        double r=fabs(dis-s);
        //printf("Side=%d\n",side);
        if(side==0){
            y=0;
            x=r;
        }
        else if(side==1){
            x=a;
            y=r;
        }
        else if(side==2){
            y=a;
            x=a-r;
        }
        else if(side==3){
            y=a-r;
            x=0;
        }
        printf("%.10lf %.10lf\n",x,y);
    }
}


// IN the name of Allah
/*
ID: ahmed.m4
PROG:
LANG: C++
*/
//s/stdc++.h>
#include <string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <limits.h>
#include <string>
#define PI 3.14159265
#define cell(i,j) ((i)*m+(j))
using namespace std;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int setbit(int n,int idx){return n|1<<idx;}
int countbits(int n){int ret=0;while(n){if(n&1)ret++;n/=2;};return ret;}
int getbit(int n,int idx){return ((n >> idx) & 1) ==1 ;}
typedef pair<double,double>ii;
typedef bitset<20>mask;
int main()
{
  //freopen("test.in","r",stdin);
  //freopen("test.out","w",stdout);
   double d,a,x=0.0,y=0.0;
  int n;
  scanf("%lf%lf%d",&a,&d,&n);
  for(int i=1;i<=n;i++)
  {
   double z=d*i;
   z=fmod(z,a*4);
   x=0.0,y=0.0;
   while(z>0.0)
   {
    if(y==0.0||y==a)
    {
     if(y==0.0&&x!=a)
     {
         if(z-(a-x)>=0.00001)z-=(a-x),x=a;
         else x+=z,z=0.0;
     }
     if(y==a&&x!=0.0)
     {
         if(z-x>=0.00001)
         z-=x,x=0.0;
         else
         x-=z,z=0.0;
     }
    }
    if(!z)break;
    if(x==0.0||x==a)
    {
     if(x==0.0&&y!=0.0)
     {
         if(z-y>=0.00001)z-=y,y=0.0;
         else y-=z,z=0.0;
     }
     if(x==a&&y!=a)
     {
         if(z-(a-y)>=0.00001)z-=(a-y),y=a;
         else
         y+=z,z=0.0;
     }
    }
   }
   printf("%lf %lf\n",x,y);
  }
 return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main () {
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	char* arr = new char[n * m]();
	while (k--) {
		int cell, x, y;
		cin >> x >> y;
		cell = (x - 1)*m + y;
		arr[cell - 1] = 'b';
	}
	int counter = 0;
	for (int i = 0; i < n * m; i++) {
		if (arr[i] == 'b')
			continue;
		else if (counter == 0)
			arr[i] = 'c';
		else if (counter == 1)
			arr[i] = 'k';
		else if (counter == 2) {
			arr[i] = 'g';
			counter = -1;
		}
		counter++;
	}
	while (t--) {
		int cell,x, y;
		cin >> x >> y;
		cell = (x - 1) * m + y;

		switch (arr[cell - 1]) {
		case 'b':cout << "Waste\n"; break;
		case 'c': cout << "Carrot\n"; break;
		case 'k':cout << "Kiwi\n"; break;
		case 'g':cout << "Grapes\n"; break;
		}
	}

}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main () {
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	char* arr = new char[n * m]();
	while (k--) {
		int cell, x, y;
		cin >> x >> y;
		cell = (x - 1)*m + y;
		arr[cell - 1] = 'b';
	}
	int counter = 0;
	for (int i = 0; i < n * m; i++) {
		if (arr[i] == 'b')
			continue;
		else if (counter == 0)
			arr[i] = 'c';
		else if (counter == 1)
			arr[i] = 'k';
		else if (counter == 2) {
			arr[i] = 'g';
			counter = -1;
		}
		counter++;
	}
	while (t--) {
		int cell,x, y;
		cin >> x >> y;
		cell = (x - 1) * m + y;

		switch (arr[cell - 1]) {
		case 'b':cout << "Waste\n"; break;
		case 'c': cout << "Carrots\n"; break;
		case 'k':cout << "Kiwis\n"; break;
		case 'g':cout << "Grapes\n"; break;
		}
	}

}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }
    int row[1010],column[1010];
    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    int wasteAccumlate[100100];
    wasteAccumlate[1] = wasteCount[1];
    for(int j=2;j<n;j++){
            wasteAccumlate[j] =wasteAccumlate[j-1]+wasteCount[j];
    }

    for(int i = 0 ; i<t;i++){
        int waste=wasteAccumlate[row[i]-1];

        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }

        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }
    int row[1010],column[1010];
    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    int wasteAccumlate[100100];
    wasteAccumlate[1] = wasteCount[1];
    for(int j=0;j<n;j++){
            wasteAccumlate[j] = 0;
    }
    for(int j=2;j<n;j++){
            wasteAccumlate[j] =wasteAccumlate[j-1]+wasteCount[j];
    }

    for(int i = 0 ; i<t;i++){
        int waste=wasteAccumlate[row[i]-1];

        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }

        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }
    int row[1010],column[1010];
    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    int wasteAccumlate[10010];
    wasteAccumlate[1] = wasteCount[1];
    for(int j=2;j<n;j++){
            wasteAccumlate[j] =wasteAccumlate[j-1]+wasteCount[j];
    }

    for(int i = 0 ; i<t;i++){
        int waste=wasteAccumlate[row[i]-1];

        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }

        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }
    int row[1010],column[1010];
    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    for(int i = 0 ; i<t;i++){
        int waste=0;
        for(int j=1;j<row[i];j++){
            waste+=wasteCount[j];
        }
        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }
        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int wasteAccumlate[100100];
int row[1010],column[1010];
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    wasteCount[1]=0;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }

    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    for(int j=0;j<n;j++){
            wasteAccumlate[j] = 0;
    }

    wasteAccumlate[1] = wasteCount[1];

    for(int j=2;j<n;j++){
            wasteAccumlate[j] =wasteAccumlate[j-1]+wasteCount[j];
    }

    for(int i = 0 ; i<t;i++){
        int waste=wasteAccumlate[row[i]-1];

        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }

        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map< int,vector<int> >wastePositions ;
map< int,int >wasteCount ;
map<pair<int,int>,int> q;
int wasteAccumlate[100100];
int row[1010],column[1010];
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int a,b;
    wasteCount[1]=0;
    for(int i = 0 ; i<k;i++){
        cin>>a>>b;
        wastePositions[a].push_back(b);
        wasteCount[a]=wastePositions[a].size();
        q[{a,b}]=10;
    }

    for(int i = 0 ; i<t;i++){
        cin>>a>>b;
        row[i]=a;column[i]=b;
    }

    wasteAccumlate[1] = wasteCount[1];

    for(int j=0;j<n;j++){
            wasteAccumlate[j] = 0;
    }
    for(int j=2;j<n;j++){
            wasteAccumlate[j] =wasteAccumlate[j-1]+wasteCount[j];
    }

    for(int i = 0 ; i<t;i++){
        int waste=wasteAccumlate[row[i]-1];

        for(int j=0;j<wastePositions[row[i]].size();j++){
            if(column[i]>wastePositions[row[i]][j]){
                waste+=1;
            }
        }

        //cout<<waste<<endl;

        int answer = (row[i]-1)*m+column[i]-waste;
        //cout<<answer<<endl;
        int a = answer%3;
        //cout<<"test"<<wastePositions[row[i]][column[i]]<<endl;
        if(q[ { row[i],column[i] } ]==10){
            cout<<"Waste"<<endl;
        }else{
            if(a==0){
                cout<<"Grapes"<<endl;
            }else if (a==1){
                cout<<"Carrots"<<endl;
            }else if (a==2){
                cout<<"Kiwis"<<endl;
            }
        }
    }

    return 0;
}


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

const int maxn = 10000;
char arr[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

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

	for(int i = 0; i < k; i ++){
		int a, b;
		cin >> a >> b;
		arr[a][b] = 'W';
	}
	char x = 'C';
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j ++){
			if(arr[i][j] != 'W'){
				arr[i][j] = x;
				if(x == 'C')
					x = 'K';
				else if(x == 'K')
					x = 'G';
				else
					x = 'C';
			}
		}
	}

	for(int i = 0; i < t; i ++){
		int a, b;
		cin >> a >> b;
		if(arr[a][b] == 'W')
			cout << "Waste" << endl;
		else if(arr[a][b] == 'G')
			cout << "Grapes" << endl;
		else if(arr[a][b] == 'C')
			cout << "Carrots" << endl;
		else
			cout << "Kiwis" << endl;
	}

	return 0;
}


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

const int maxn = 10000 * 4;
char arr[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

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

	for(int i = 0; i < k; i ++){
		int a, b;
		cin >> a >> b;
		arr[a][b] = 'W';
	}
	char x = 'C';
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j ++){
			if(arr[i][j] != 'W'){
				arr[i][j] = x;
				if(x == 'C')
					x = 'K';
				else if(x == 'K')
					x = 'G';
				else
					x = 'C';
			}
		}
	}

	for(int i = 0; i < t; i ++){
		int a, b;
		cin >> a >> b;
		if(arr[a][b] == 'W')
			cout << "Waste" << endl;
		else if(arr[a][b] == 'G')
			cout << "Grapes" << endl;
		else if(arr[a][b] == 'C')
			cout << "Carrots" << endl;
		else
			cout << "Kiwis" << endl;
	}

	return 0;
}


//#include <GOD>

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

typedef long long ll;
#define si size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define E end()
#define B begin()
#define pi pair<int, int>
#define en cout << endl
#define cn const
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
	fast_io;
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	map <pair <int, int> , string> mpp;
	vector <int> row;
	vector <int> col;
	for(int i = 0; i < k; i ++){
		int x, y;
		cin >> x >> y;
		mpp[mp(x, y)] = "Waste";
		row.pb(x);
		col.pb(y);
	}

	for(int i = 0; i < t; i ++){
		int x, y;
		cin >> x >> y;
		if(mpp[mp(x, y)] != "Waste"){
			int cnt = 0;
			for(int j = 0; j < row.si; j ++){
				if(row[j] < x){
					cnt ++;
				}else if(row[j] == x && col[j] < y)
					cnt ++;
			}
//			cout << "cnt = " << cnt << endl;
			if(((x - 1) * m + y - cnt) % 3 == 1)
				cout << "Carrots";
			else if(((x - 1) * m + y - cnt) % 3 == 2)
				cout << "Kiwis";
			else
				cout << "Grapes";
			en;
		}else{
			cout << mpp[mp(x, y)];
			en;
		}
	}
	return 0;
}


//#include <GOD>

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

typedef long long ll;
#define si size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define E end()
#define B begin()
#define pi pair<int, int>
#define en cout << endl
#define cn const
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
	fast_io;
	int n, m, k, t;
	cin >> n >> m >> k >> t;
	map <pair <int, int> , string> mpp;
	for(int i = 0; i < k; i ++){
		int x, y;
		cin >> x >> y;
		mpp[mp(x, y)] = "Waste";
	}
	string cr = "Carrots";
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if(mpp[mp(i, j)] != "Waste"){
				mpp[mp(i, j)] = cr;
				if(cr == "Carrots")
					cr = "Kiwis";
				else if(cr == "Kiwis"){
					cr = "Grapes";
				}else{
					cr = "Carrots";
				}
			}
		}
	}
	for(int i = 0; i < t; i ++){
		int x, y;
		cin >> x >> y;
		cout << mpp[mp(x, y)];
		en;
	}
	return 0;
}


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

const int maxn = 10000;
char arr[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

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

	for(int i = 0; i < k; i ++){
		int a, b;
		cin >> a >> b;
		arr[a][b] = 'W';
	}
	char x = 'C';
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if(arr[i][j] != 'W'){
				arr[i][j] = x;
				if(x == 'C')
					x = 'K';
				else if(x == 'K')
					x = 'G';
				else
					x = 'C';
			}
		}
	}

	for(int i = 0; i < t; i ++){
		int a, b;
		cin >> a >> b;
		if(arr[a][b] == 'W')
			cout << "Waste" << endl;
		else if(arr[a][b] == 'G')
			cout << "Grapes" << endl;
		else if(arr[a][b] == 'C')
			cout << "Carrots" << endl;
		else
			cout << "Kiwis" << endl;
	}

	return 0;
}


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

const int maxn = 10000 * 4 + 10;
char arr[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

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

	for(int i = 0; i < k; i ++){
		int a, b;
		cin >> a >> b;
		arr[a][b] = 'W';
	}
	char x = 'C';
	for(int i = 0; i < n; i ++){
		for(int j = 0; j < m; j ++){
			if(arr[i][j] != 'W'){
				arr[i][j] = x;
				if(x == 'C')
					x = 'K';
				else if(x == 'K')
					x = 'G';
				else
					x = 'C';
			}
		}
	}

	for(int i = 0; i < t; i ++){
		int a, b;
		cin >> a >> b;
		if(arr[a][b] == 'W')
			cout << "Waste" << endl;
		else if(arr[a][b] == 'G')
			cout << "Grapes" << endl;
		else if(arr[a][b] == 'C')
			cout << "Carrots" << endl;
		else
			cout << "Kiwis" << endl;
	}

	return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k ,t;
    cin >> n >> m >> k >> t;
    vector<vector<char>> mat(n, vector<char>(m, '0'));
    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        mat[x-1][y-1] = '.';
    }
    int cycle = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (mat[i][j] != '.') {
                if (cycle == 0) mat[i][j] = 'C';
                else if (cycle == 1) mat[i][j] = 'K';
                else if (cycle == 2) mat[i][j] = 'G';
                cycle++;
                cycle %= 3;
            }
        }
    }
    while (t--) {
        int x, y;
        cin >> x >> y;
        switch (mat[x-1][y-1])
        {
        case '.':
            cout << "Waste" << '\n';
            break;

        case 'C':
            cout << "Carrots" << '\n';
            break;
        case 'K':
            cout << "Kiwis" << '\n';
            break;
        case 'G':
            cout << "Grapes" << '\n';
            break;
        }
    }
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k ,t;
    cin >> n >> m >> k >> t;
    vector<vector<char>> mat(n, vector<char>(m, '0'));
    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        mat[x-1][y-1] = '.';
    }
    int cycle = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (mat[i][j] != '.') {
                if (cycle == 0) mat[i][j] = 'C';
                else if (cycle == 1) mat[i][j] = 'K';
                else if (cycle == 2) mat[i][j] = 'G';
                cycle++;
                cycle %= 3;
            }
        }
    }
    while (t--) {
        int x, y;
        cin >> x >> y;
        switch (mat[x-1][y-1])
        {
        case '.':
            cout << "Waste" << '\n';
            break;

        case 'C':
            cout << "Carrot" << '\n';
            break;
        case 'K':
            cout << "Kiwis" << '\n';
            break;
        case 'G':
            cout << "Grapes" << '\n';
            break;
        }
    }
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k ,t;
    cin >> n >> m >> k >> t;
    vector<pair<int, int>> s;
    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        s.push_back({x, y});
    }
  // sort(s.begin(), s.end());
    while (t--) {
        int a, b;
        cin >> a >> b;
        pair<int, int> temp = {a, b};
        int ct = 0;
        bool flag = 0;
        for (int i=0; i<s.size(); i++) {
            if (temp <= s[i]) {
                if (temp == s[i]) flag = 1;
                break;
            }
            ct++;
        }
        if (flag) cout << "Waste" << '\n';
        else {
            int i = (a-1)*m + (b-1);
            int ans = (i - ct) % 3;
            if (ans % 3 == 0) cout << "Carrots" << '\n';
            else if (ans % 3 == 1) cout << "Kiwis" << '\n';
            else if (ans % 3 == 2) cout << "Grapes" << '\n';
        }
    }
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k ,t;
    cin >> n >> m >> k >> t;
    vector<vector<char>> mat(n, vector<char>(m, '0'));
    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        mat[x-1][y-1] = '.';
    }
    int cycle = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (mat[i][j] != '.') {
                if (cycle == 0) mat[i][j] = 'C';
                else if (cycle == 1) mat[i][j] = 'K';
                else if (cycle == 2) mat[i][j] = 'G';
                cycle++;
                cycle %= 3;
            }
        }
    }
    while (t--) {
        int x, y;
        cin >> x >> y;
        string ans = "";
        switch (mat[x-1][y-1])
        {
        case '.':
            ans = "Waste";
            break;

        case 'C':
            ans = "Carrots";
            break;
        case 'K':
            ans = "Kiwis";
            break;
        case 'G':
            ans = "Grapes";
            break;
        }
        cout << ans << '\n';
    }
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, k ,t;
    cin >> n >> m >> k >> t;
    vector<pair<int, int>> s;
    for (int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;
        s.push_back({x, y});
    }
    sort(s.begin(), s.end());
    while (t--) {
        int a, b;
        cin >> a >> b;
        pair<int, int> temp = {a, b};
        int ct = 0;
        bool flag = 0;
        for (int i=0; i<s.size(); i++) {
            if (temp <= s[i]) {
                if (temp == s[i]) flag = 1;
                break;
            }
            ct++;
        }
        if (flag) cout << "Waste" << '\n';
        else {
            int i = (a-1)*m + (b-1);
            int ans = (i - ct) % 3;
            if (ans % 3 == 0) cout << "Carrots" << '\n';
            else if (ans % 3 == 1) cout << "Kiwis" << '\n';
            else if (ans % 3 == 2) cout << "Grapes" << '\n';
        }
    }
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==0) {}
       else{ jok[i][j]=co;
        if(co==3) co=0;
        co++;}
    }
   for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
         cout<<jok[i][j]<<" ";
    }
    cout<<endl;
   }
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    map<int,int>mp;
    int jok[k];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        mp[x]=y;
        jok[i]=(x-1)*m+y;
    }
    sort(jok,jok+k);
    int co;
    for(int i=0;i<t;i++){
        cin>>x>>y;
        co=(x-1)*m+y;
            int d=0;
            for(int j=0;j<k;j++){
                if(jok[j]<co) d++;
                else if (jok[j]==co) {d=-1; break;}
                else break;
            }
            co=co-d;
            co=co%3;
        if(d==-1) cout<<"Waste";
        else if(co==1) cout<<"Carrots";
        else if(co==2) cout<<"Kiwis";
        else if(co==0) cout<<"Grapes";

    if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=-2;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==-2) continue;
       jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
  /* for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
         cout<<jok[i][j]<<" ";
    }
    cout<<endl;
   }*/
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==-2) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <cstdio>
#include <stack>
#include <iostream>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
        if(jok[i][j]==0) continue;
        jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
        if(jok[i][j]==0) continue;
        jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    map<int,int>mp;
    int jok[k];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        mp[x]=y;
        jok[i]=(x-1)*m+y;
    }
    sort(jok,jok+k);
    int co;
    for(int i=0;i<t;i++){
        cin>>x>>y;
        co=(x-1)*m+y;
        if(mp[x]==y) cout<<"Waste";
        else{
            int d=0;
            for(int j=0;j<k;j++){
                if(jok[j]<co) d++;
                else break;
            }
            co=co-d;
            co=co%3;
        if(co==1) cout<<"Carrots";
        else if(co==2) cout<<"Kiwis";
        else if(co==0) cout<<"Grapes";
        }
    if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==0) {}
       else{ jok[i][j]=co;
        if(co==3) co=0;
        co++;}
    }

    for(int i=0;i<t;i++){
        cin>>x>>y;
        cout<<jok[x-1][y-1]<<endl;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==0) {}
       else{ jok[i][j]=co;
        if(co==3) co=0;
        co++;}
    }

    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[n][m];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=1437;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==1437) continue;
       jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
  /* for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
         cout<<jok[i][j]<<" ";
    }
    cout<<endl;
   }*/
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==1437) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <stack>
#include <iostream>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
        if(jok[i][j]==0) continue;
        jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=1437;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==1437) continue;
       jok[i][j]=co;
        if(co==3) co=0;
        co++;
    }
  /* for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
         cout<<jok[i][j]<<" ";
    }
    cout<<endl;
   }*/
    for(int i=0;i<t;i++){
        cin>>x>>y;
        if(jok[x-1][y-1]==1437) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    map<int,int>mp;
    int jok[k];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        mp[x]=y;
        jok[i]=(x-1)*m+y;
    }
    sort(jok,jok+k);
    int co;
    for(int i=0;i<t;i++){
        cin>>x>>y;
        co=(x-1)*m+y;
            int d=0;
            for(int j=0;j<k;j++){
                if(jok[j]<co) d++;
                else if (jok[j]==co) {d=-1; break;}
                else break;
            }
            //jjsjdshdsjh
            co=co-d;
            co=co%3;
        if(d==-1) cout<<"Waste";
        else if(co==1) cout<<"Carrots";
        else if(co==2) cout<<"Kiwis";
        else if(co==0) cout<<"Grapes";

    if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include <iostream>

using namespace std;

int main() {

	int n,m,k,t;
	cin>>n>>m>>k>>t;
    int jok[4][5];
    int x,y;
    for(int i=0;i<k;i++){
        cin>>x>>y;
        jok[x-1][y-1]=0;
    }
    int co=1;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++){
        if(jok[i][j]==0) {}
       else{ jok[i][j]=co;
        if(co==3) co=0;
        co++;}
    }

    for(int i=0;i<t;i++){
        cin>>x>>y;
        cout<<jok[x-1][[y-1]<<endl;
        if(jok[x-1][y-1]==0) cout<<"Waste";
        else if(jok[x-1][y-1]==1) cout<<"Carrots";
        else if(jok[x-1][y-1]==2) cout<<"Kiwis";
        else if(jok[x-1][y-1]==3) cout<<"Grapes";
        if(i!=t-1) cout<<endl;

    }

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
const int maxN=4e4;
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>

int main()
{
    int n,m,k,t;
    cin >> n >> m >> k >> t;
    int a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            a[i][j]=0;
    }
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        a[x][y]=-1;
    }
    int add=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]==0)
            {
                a[i][j]+=add;
                add++;
            }
        }
    }
    for(int i=0;i<t;i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        if(a[x][y]==-1)
            cout << "Waste\n";
        else if(a[x][y]%3==1)
            cout << "Carrots\n";
        else if(a[x][y]%3==2)
            cout << "Kiwis\n";
        else if(a[x][y]%3==0)
            cout << "Grapes\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
const int maxN=4e4;
const int maxxN=2e9;
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>

int main()
{
    int n,m,k,t;
    cin >> n >> m >> k >> t;
    vector< pair <int,int> > a;
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        a.pb(mp(x,y));
    }
    while(t--)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        int count=0;
        bool print=false;
        for(int i=0;i<n;i++)
        {
            if(a[i].first<=x)
            {
                if(a[i].second<=y)
                {
                    count++;
                }
            }
            if(a[i].first==x&&a[i].second==y)
            {
                cout << "Waste\n";
                print=true;
            }
        }
        if(!print)
        {
            if((x*m+y+1-count)%3==1)
                cout << "Carrots\n";
            else if((x*m+y+1-count)%3==2)
                cout << "Kiwis\n";
            else if((x*m+y+1-count)%3==0)
                cout << "Grapes\n";
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
const int maxN=4e4;
const int maxxN=2e9;
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>

int main()
{
    int n,m,k,t;
    cin >> n >> m >> k >> t;
    vector< pair <int,int> > a;
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x,y;
        a.pb(mp(x,y));
    }
    while(t--)
    {
        int x,y;
        cin >> x >> y;
        x,y;
        int count=0;
        bool print=false;
        for(int i=0;i<n;i++)
        {
            if(a[i].first<x)
            {
                count++;
            }
            if(a[i].first==x&&a[i].second<y)
            {
                count++;
            }
            //cout << a[i].first << " " << a[i].second << "\n";
            if(a[i].first==x&&a[i].second==y)
            {
                cout << "Waste\n";
                print=true;
            }
        }
        if(!print)
        {
            //cout << x << " " << y << " " << count << "\n";
            if(((x-1)*m+y-count)%3==1)
                cout << "Carrots\n";
            else if(((x-1)*m+y-count)%3==2)
                cout << "Kiwis\n";
            else if(((x-1)*m+y-count)%3==0)
                cout << "Grapes\n";
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
const int maxN=4e4;
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>

int main()
{
    int n,m,k,t;
    cin >> n >> m >> k >> t;
    vector<vector<int>> a;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            a[i][j]=0;
    }
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        a[x][y]=-1;
    }
    int add=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]==0)
            {
                a[i][j]+=add;
                add++;
            }
        }
    }
    for(int i=0;i<t;i++)
    {
        int x,y;
        cin >> x >> y;
        x--,y--;
        if(a[x][y]==-1)
            cout << "Waste\n";
        else if(a[x][y]%3==1)
            cout << "Carrots\n";
        else if(a[x][y]%3==2)
            cout << "Kiwis\n";
        else if(a[x][y]%3==3)
            cout << "Grapes\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxN=2e5;
const int maxN=4e4;
const int maxxN=2e9;
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>

int main()
{
    int n,m,k,t;
    cin >> n >> m >> k >> t;
    vector< pair <int,int> > a;
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y;
        x,y;
        a.pb(mp(x,y));
    }
    while(t--)
    {
        int x,y;
        cin >> x >> y;
        x,y;
        int count=0;
        bool print=false;
        for(int i=0;i<a.size();i++)
        {
            if(a[i].first<x)
            {
                count++;
            }
            if(a[i].first==x&&a[i].second<y)
            {
                count++;
            }
            //cout << a[i].first << " " << a[i].second << "\n";
            if(a[i].first==x&&a[i].second==y)
            {
                cout << "Waste\n";
                print=true;
            }
        }
        if(!print)
        {
            //cout << x << " " << y << " " << count << "\n";
            if(((x-1)*m+y-count)%3==1)
                cout << "Carrots\n";
            else if(((x-1)*m+y-count)%3==2)
                cout << "Kiwis\n";
            else if(((x-1)*m+y-count)%3==0)
                cout << "Grapes\n";
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=4*10000+5, a, b, p=0; int field[] = {1,2,3,4};
	cin >> n >> m >> k >> t; int arr[N][N];
	fo(i, k) {
		cin >> a >> b; arr[a-1][b-1] = 4;
	}
	fo(i, n) {
		fo(j, m) {
			if(arr[i][j] == 4) continue;
			arr[i][j] = field[p%3];
			p++;
		}
	}
	fo(i, t) {
		cin >> a >> b;
		if(arr[a-1][b-1] == 4) cout << "Waste\n";
		else if(arr[a-1][b-1] == 3) cout << "Grapes\n";
		else if(arr[a-1][b-1] == 2) cout << "Kiwis\n";
		else cout << "Carrots\n";
	}
}

int main() {
	// #ifndef ONLINE
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=1e4+5, a, b, p=0; int field[] = {1,2,3,4};
	cin >> n >> m >> k >> t; int arr[N][N];
	fo(i, k) {
		cin >> a >> b; arr[a-1][b-1] = 4;
	}
	fo(i, n) {
		fo(j, m) {
			if(arr[i][j] == 4) continue;
			arr[i][j] = field[p%3];
			p++;
		}
	}
	fo(i, t) {
		cin >> a >> b;
		if(arr[a-1][b-1] == 4) cout << "Waste\n";
		else if(arr[a-1][b-1] == 3) cout << "Grapes\n";
		else if(arr[a-1][b-1] == 2) cout << "Kiwis\n";
		else cout << "Carrots\n";
	}
}

int main() {
	// #ifndef ONLINE
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=4e4+13, a, b, p=0; char field[] = {'c','k','g','w'};
	cin >> n >> m >> k >> t; vector<vector<char>> arr(N, vector<char>(N));
	fo(i, k) {
		cin >> a >> b; arr[a-1][b-1] = 'w';
	}
	fo(i, n) {
		fo(j, m) {
			if(arr[i][j] == 'w') continue;
			arr[i][j] = field[p%3];
			p++;
		}
	}
	fo(i, t) {
		cin >> a >> b;
		if(arr[a-1][b-1] == 'w') cout << "Waste\n";
		else if(arr[a-1][b-1] == 'g') cout << "Grapes\n";
		else if(arr[a-1][b-1] == 'k') cout << "Kiwis\n";
		else cout << "Carrots\n";
	}
}

int main() {
	// #ifndef ONLINE
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=4*10000+5, a, b, p=0; char field[] = {'c','k','g','w'};
	cin >> n >> m >> k >> t; vector<vector<char>> arr(N, vector<char>(N));
	fo(i, k) {
		cin >> a >> b; arr[a-1][b-1] = 'w';
	}
	fo(i, n) {
		fo(j, m) {
			if(arr[i][j] == 'w') continue;
			arr[i][j] = field[p%3];
			p++;
		}
	}
	fo(i, t) {
		cin >> a >> b;
		if(arr[a-1][b-1] == 'w') cout << "Waste\n";
		else if(arr[a-1][b-1] == 'g') cout << "Grapes\n";
		else if(arr[a-1][b-1] == 'k') cout << "Kiwis\n";
		else cout << "Carrots\n";
	}
}

int main() {
	// #ifndef ONLINE
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=4e4+13, a, b, p=0; bool flag = 0;
	cin >> n >> m >> k >> t; vpii umap;
	fo(i, k) {
		cin >> a >> b; umap.push_back(make_pair(a,b));
	}
	fo(i, t) {
		cin >> a >> b; flag = 0;
		fo(i, umap.size()) {
			if(umap[i].first == a && umap[i].second == b) {
				cout << "Waste\n"; flag = 1; break;
			}
		}
		if(!flag) {
			int cells = (a-1)*m + b, c=0;
			fo(i, umap.size()) {
				if(umap[i].first < a)
					c++;
			}
			cells -= c; c = 0;
			fo(i, umap.size()) {
				if(umap[i].first == a && umap[i].second < b) c++;
			}
			cells -= c;
			if(cells % 3 == 1) cout << "Carrots\n";
			else if(cells % 3 == 2) cout << "Kiwis\n";
			else cout << "Grapes\n";
		}
	}
}

int main() {
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
// const int MOD = 1000000007;
// const int N = 2e6+13, M = N;
//=======================
// vi g[N];
// int a[N];
int n, m, k, v;
//=======================

void solve() {
	int t, N=4e4+13, a, b, p=0; bool flag = 0;
	cin >> n >> m >> k >> t; vpii umap;
	fo(i, k) {
		cin >> a >> b; umap.push_back(make_pair(a,b));
	}
	fo(i, t) {
		cin >> a >> b; flag = 0;
		fo(i, umap.size()) {
			if(umap[i].first == a && umap[i].second == b) {
				cout << "Waste\n"; flag = 1; break;
			}
		}
		if(!flag) {
			int cells = (a-1)*m + b, c=0;
			fo(i, umap.size()) {
				if(umap[i].first < a)
					c++;
			}
			cells -= c; c = 0;
			for(int i = 1; i<=b; i++) {
				if(umap[i].first == a && umap[i].second < b) c++;
			}
			cells -= c;
			if(cells % 3 == 1) cout << "Carrots\n";
			else if(cells % 3 == 2) cout << "Kiwis\n";
			else cout << "Grapes\n";
		}
	}
}

int main() {
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif

    // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
    // int t = 1;
    // cin >> t;
    // while(t--) {
    //   solve();
    // }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> arr;

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    while(k--){
        int a,b; scanf("%d%d",&a,&b);
        arr.push_back(a*m+b);
    }
    sort(arr.begin(),arr.end());
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        int lb=lower_bound(arr.begin(),arr.end(),a*m+b)-arr.begin();
        if(lb!=arr.size()&&arr[lb]==a*m+b)printf("Waste\n");
        else{
            int num = (a*m+b-lb)%3;
            if(!num)printf("Carrots\n");
            else if(num==1)printf("Kiwis\n");
            else printf("Grapes\n");
        }
    }
}


#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> arr(40005);

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            arr[i].push_back(0);
        }
    }
    while(k--){
        int a,b; scanf("%d%d",&a,&b);
        arr[--a][--b]=-1;
    }
    int c=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(!arr[i][j]){arr[i][j]=c;c++;}
            if(c==4)c=1;
        }
    }
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        if(arr[a][b]==1)printf("Carrots\n");
        else if(arr[a][b]==2)printf("Kiwis\n");
        else if(arr[a][b]==3)printf("Grapes\n");
        else printf("Waste\n");
    }
}


#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> arr(40005);

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            arr[i].push_back(0);
        }
    }
    while(k--){
        int a,b; scanf("%d%d",&a,&b);
        arr[--a][--b]=-1;
    }
    int c=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(!arr[i][j]){arr[i][j]=c;c++;}
            if(c==4)c=1;
        }
    }
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        a--;b--;
        if(arr[a][b]==1)printf("Carrots\n");
        else if(arr[a][b]==2)printf("Kiwis\n");
        else if(arr[a][b]==3)printf("Grapes\n");
        else printf("Waste\n");
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> arr;

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    while(k--){
        int a,b; scanf("%d%d",&a,&b);
        arr.push_back(a*m+b);
    }
    sort(arr.begin(),arr.end());
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        int lb=lower_bound(arr.begin(),arr.end(),a*m+b)-arr.begin();
        if(lb!=arr.size()&&arr[lb]==a*m+b)printf("Waste\n");
        else{
            int num = (a*m+b-lb-1)%3;
            if(!num)printf("Carrots\n");
            else if(num==1)printf("Kiwis\n");
            else printf("Grapes\n");
        }
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> arr;

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    while(k--){
        int a,b; scanf("%d%d",&a,&b);a--;b--;
        arr.push_back(a*m+b);
    }
    sort(arr.begin(),arr.end());
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        a--;b--;
        int lb=lower_bound(arr.begin(),arr.end(),a*m+b)-arr.begin();
        if(lb!=arr.size()&&arr[lb]==a*m+b)printf("Waste\n");
        else{
            int num = (a*m+b-lb)%3;
            if(!num)printf("Carrots\n");
            else if(num==1)printf("Kiwis\n");
            else printf("Grapes\n");
        }
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> arr;

int main()
{
    int n,m,k,t; scanf("%d%d%d%d",&n,&m,&k,&t);
    while(k--){
        int a,b; scanf("%d%d",&a,&b);a--;b--;
        arr.push_back(a*m+b);
    }
    sort(arr.begin(),arr.end());
    while(t--){
        int a,b; scanf("%d%d",&a,&b);
        a--;b--;
        int lb=lower_bound(arr.begin(),arr.end(),a*m+b)-arr.begin();
        if(lb!=arr.size()&&arr[lb]==a*m+b)printf("Waste\n");
        else{
            int num = (a*m+b-lb)%3;
            if(!num)printf("Carrots\n");
            else if(num==1)printf("Kiwis\n");
            else printf("Grapes\n");
        }
    }
}
//


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;
vector <int >v;
vector <int >v2;
vector <string >v3;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        int x=b+((a-1)*m);
        v.push_back(x);

    }
    sort(v.begin(),v.end());
    int si=v.size();
    for(int i=0;i<t;i++)
    {
        int y,z;
        cin>>y>>z;
        int r=z+((y-1)*m);
        int u=r;
        bool b=false;
        for(int i=0;i<si;i++)
        {
            if(r==v[i])
                {
                    v3.push_back("waste");
                    b=true;
                }
            else if(v[i]<r)
            {
                u--;
            }
            else if(v[i]>r)
                break;

        }
        if (b==false)
        {
            if(u %3 ==0)
               v3.push_back("Grapes");
            else if(u%3 ==1)
                v3.push_back("Carrots");
            else
                v3.push_back("Kiwis");

        }
    }
    for(int i=0;i<v3.size();i++)
        cout<<v3[i]<<endl;

}


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;
vector <int >v;
vector <int >v2;
vector <string >v3;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        int x=b+((a-1)*m);
        v.push_back(x);

    }
    sort(v.begin(),v.end());
    int si=v.size();
    for(int i=0;i<t;i++)
    {
        int y,z;
        cin>>y>>z;
        int r=z+((y-1)*m);
        int u=r;
        bool b=false;
        for(int i=0;i<si;i++)
        {
            if(r==v[i])
                {
                    v3.push_back("Waste");
                    b=true;
                }
            else if(v[i]<r)
            {
                u--;
            }

        }
        if (b==false)
        {
            if(u %3 ==0)
               v3.push_back("Grapes");
            else if(u%2 ==0)
                v3.push_back("Kiwis");
            else
                v3.push_back("Carrots");

        }
    }
    for(int i=0;i<v3.size();i++)
        cout<<v3[i]<<endl;

}


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;
vector <int >v;
vector <int >v2;
vector <string >v3;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        int x=b+((a-1)*m);
        v.push_back(x);

    }
    sort(v.begin(),v.end());
    int si=v.size();
    for(int i=0;i<t;i++)
    {
        int y,z;
        cin>>y>>z;
        int r=z+((y-1)*m);
        int u=r;
        bool b=false;
        for(int i=0;i<si;i++)
        {
            if(r==v[i])
                {
                    v3.push_back("waste");
                    b=true;
                }
            else if(v[i]<r)
            {
                u--;
            }

        }
        if (b==false)
        {
            if(u %3 ==0)
               v3.push_back("Grapes");
            else if(u%2 ==0)
                v3.push_back("Kiwis");
            else
                v3.push_back("Carrots");

        }
    }
    for(int i=0;i<v3.size();i++)
        cout<<v3[i]<<endl;

}


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;
vector <int >v;
vector <int >v2;
vector <string >v3;
int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        int x=b+((a-1)*m);
        v.push_back(x);

    }
    sort(v.begin(),v.end());
    int si=v.size();
    for(int i=0;i<t;i++)
    {
        int y,z;
        cin>>y>>z;
        int r=z+((y-1)*m);
        int u=r;
        bool b=false;
        for(int i=0;i<si;i++)
        {
            if(r==v[i])
                {
                    v3.push_back("Waste");
                    b=true;
                }
            else if(v[i]<r)
            {
                u--;
            }
            else if(v[i]>r)
                break;

        }
        if (b==false)
        {
            if(u %3 ==0)
               v3.push_back("Grapes");
            else if(u%3 ==1)
                v3.push_back("Carrots");
            else
                v3.push_back("Kiwis");

        }
    }
    for(int i=0;i<v3.size();i++)
        cout<<v3[i]<<endl;

}


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        arr[a][b]=-1;
    }
    int x=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(arr[i][j] != -1)
            {
                arr[i][j]=x;
                if(x == 3)
                    x=1;
                else
                    x++;
            }

        }

    }
    vector <string >s;
    for(int i=0;i<t;i++)
    {
        int z,y;
        cin>>z>>y;
        --z;
        --y;
        if(arr[z][y] == -1)
            s.push_back("Waste");
        else if(arr[z][y]== 1)
            s.push_back("Carrots");
        else if(arr[z][y]== 2)
            s.push_back("Kiwis");
        else if(arr[z][y]== 3)
            s.push_back("Grapes");
    }
    int r=s.size();
    for(int i=0;i<r;i++)
    {
        cout<<s[i]<<endl;
    }

}


#include <iostream>
#include <string>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,k,t;
    cin>>n>>m>>k>>t;
    int arr[n][m];
    for(int i=0 ;i<k;i++)
    {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        arr[a][b]=-1;
    }
    int x=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(arr[i][j] != -1)
            {
                arr[i][j]=x;
                if(x == 3)
                    x=1;
                else
                    x++;
            }

        }

    }
    for(int i=0;i<t;i++)
    {
        int z,y;
        cin>>z>>y;
        --z;
        --y;
        if(arr[z][y] == -1)
            cout<<" Waste"<<endl;
        else if(arr[z][y]== 1)
            cout<<"Carrots"<<endl;
        else if(arr[z][y]== 2)
            cout<<"Kiwis"<<endl;
        else if(arr[z][y]== 3)
            cout<<"Grapes"<<endl;
    }

}


#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);
ll 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;
    int ans = ((ll)(x-1) *c )+ y ;
for(int j=0;j<k;j++){
    if(p[j].first==x&&p[j].second==y)){
        ans = -10000;
        break;
    }
    else if (p[j].first<=x&&p[j].second<=y)ans--;
}
if(ans==-10000)	cout<<"Waste"<<endl;
else if (ans%3==2)cout << "Kiwis"<<endl;
else if (ans%3==1)cout << "Carrots"<<endl;
else              cout << "Grapes"<<endl;
}

}


#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 = -10000;
        break;
    }
    else if (p[j].first<=(x)&&p[j].second<=(y))ans--;
}
if(ans==-10000)	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;

#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);
ll 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;
    ll ans = ((ll)(x-1) *c )+ y ;
for(int j=0;j<k;j++){
    if(p[j].first==x&&p[j].second==y){
        ans = -10000;
        break;
    }
    else if (p[j].first<x ||(p[j].first==x &&p[j].second<= y))ans--;
}
if(ans==-10000)	cout<<"Waste"<<endl;
else if (ans%3==2)cout << "Kiwis"<<endl;
else if (ans%3==1)cout << "Carrots"<<endl;
else              cout << "Grapes"<<endl;
}

}


#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,m;
cin>>r>>c>>k>>m;
int x[r][c]={};
loop(k){
 int a,b;
 cin>>a>>b;
 x[a-1][b-1] = 4;
}
int p=1;
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      if(x[i][j] != 4){
            if(p==4)p=1;
            x[i][j] = p%3;
                 p++;
      }
    }
}
loop(m){
int a,b;
cin>>a>>b;
if(x[a-1][b-1]==1)cout<<"Carrots"<<endl;
else if(x[a-1][b-1]==2)cout<<"Kiwis"<<endl;
else if(x[a-1][b-1]==0)cout<<"Grapes"<<endl;
else cout<<"Waste"<<endl;
}

       }


#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);
ll 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;
    int ans = ((ll)(x-1) *c )+ y ;
for(int j=0;j<k;j++){
    if(p[j].first==x&&p[j].second==y){
        ans = -10000;
        break;
    }
    else if (p[j].first<=x&&p[j].second<=y)ans--;
}
if(ans==-10000)	cout<<"Waste"<<endl;
else if (ans%3==2)cout << "Kiwis"<<endl;
else if (ans%3==1)cout << "Carrots"<<endl;
else              cout << "Grapes"<<endl;
}

}


#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);
ll 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;
    int ans = ((ll)(x-1) *c )+ y ;
for(int j=0;j<k;j++){
    if(p[j].first==x&&p[j].second==y){
        ans = -10000;
        break;
    }
    else if (p[j].first<x ||(p[j].first==x &&p[j].second< y)ans--;
}
if(ans==-10000)	cout<<"Waste"<<endl;
else if (ans%3==2)cout << "Kiwis"<<endl;
else if (ans%3==1)cout << "Carrots"<<endl;
else              cout << "Grapes"<<endl;
}

}


#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;
    int ans = (x-1) * c + y ;
for(int j=0;j<k;j++){
    if(p[j].first==(x)&&p[j].second==(y)){
        ans = -10000;
        break;
    }
    else if (p[j].first<=(x)&&p[j].second<=(y))ans--;
}
if(ans==-10000)	cout<<"Waste"<<endl;
else if (ans%3==2)cout << "Kiwis"<<endl;
else if (ans%3==1)cout << "Carrots"<<endl;
else              cout << "Grapes"<<endl;
}

}