    #include <bits/stdc++.h>
    using namespace std;
    template <typename T> void read(T &t) {
    	t=0; char ch=getchar(); int f=1;
    	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
    }
    const int maxn=610;
    int n,m,x,lg;
    bool c[maxn][maxn];
    void solve() {
    	lg=0;
    	read(x);
    	while (x%4==0)
    		x/=4,lg++;
    	if (x%2==1) {
    		for (int i=0;i<2*n;i++)
    		for (int j=0;j<2*n;j++)
    			c[i][j]|=((i>>lg)+(j>>lg))&1;
    	} else {
    		for (int i=0;i<2*n;i++)
    			if (i&(1<<lg))
    				for (int j=0;j<2*n;j++) c[i][j]=1;
    	}
    }
    int main() {
    	//freopen("1.txt","r",stdin);
    	read(n);
    	solve();
    	solve();
    	int tot=0;
    	for (int i=0;i<2*n;i++)
    	for (int j=0;j<2*n;j++)
    		if (!c[i][j]) {
    			printf("%d %d\n",i,j);
    			tot++;
    			if (tot==n*n) return 0;
    		}
        return 0;
    }