#pragma GCC optimize(3)
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define N 1005
#define col2 color
using namespace std;
int n,d1,d2,kk,pos[N][N],head[600*600+6],col1[600*600+6],color[N*N];
bitset<N*N>bt1,bt2,bt3,bt4,tmp1,tmp2,tmp3,tmp4;
struct Node{int x,y;}p[N*N];
struct Edge{int nxt,to;}e[N*N*8];
vector<Node>G[3];
unordered_map<int,int> mp[2][605*605];
inline int getid(int x,int y){x++;y++;return (x-1)*(2*n)+y;}
inline int up(int x,int y){return x+y;}
inline int down(int x,int y){return x-y;}
inline void link(int x,int y){e[++kk].nxt=head[x];e[kk].to=y;head[x]=kk;}
inline void add(int x,int y,int opt){if(x==y)return;if(!mp[opt][x][y])mp[opt][x][y]=1,link(x,y);/*if(!mp[opt][y][x])mp[opt][y][x]=1,link(y,x);*/}
void dfs(int u,int col){
	color[u]=col;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (color[v]) continue;
		dfs(v,3-col);
	}
}
inline void print(bitset<N*N> xx){
	int tot=0;
	for (int i=1;i<=4*n*n;i++){
		if (xx[i]) printf("%d %d\n",p[i].x,p[i].y),tot++;
		if (tot==n*n) return;
	}
}
inline int pd(int x,int y){return (x<2*n&&x>=0&&y<2*n&&y>=0);}
int main(){
	//freopen("get.out","w",stdout);
	scanf("%d%d%d",&n,&d1,&d2);
	//n=300;d1=4545;d2=32768;
	//n=300;d1=44500;d2=102400;
	for (int i=0;i<2*n;i++)
		for (int j=i;j<2*n;j++){
			if (i*i+j*j==d1) G[1].push_back((Node){i,j}),G[1].push_back((Node){j,i});
			else if (i*i+j*j==d2) G[2].push_back((Node){i,j}),G[2].push_back((Node){j,i});
		}
	//printf("%d %d\n",G[1].size(),G[2].size());return 0;
	for (int i=0;i<2*n;i++)
		for (int j=0;j<2*n;j++) pos[i][j]=getid(i,j),p[getid(i,j)]=(Node){i,j};
	for (int i=0;i<2*n;i++){
		for (int j=0;j<2*n;j++){
			for (int k=0;k<(int)G[1].size();k++){
				int tx=G[1][k].x;int ty=G[1][k].y;
				int x=up(i,tx);int y=up(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],0)/*,add(pos[y][x],pos[j][i],0)*/;
				x=up(i,tx);y=down(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],0)/*,add(pos[y][x],pos[j][i],0)*/;
				x=down(i,tx);y=up(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],0)/*,add(pos[y][x],pos[j][i],0)*/;
				x=down(i,tx);y=down(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],0)/*,add(pos[y][x],pos[j][i],0)*/;
			}
		}
	}//puts("nan");
	for (int i=1;i<=4*n*n;i++) if (!color[i]) dfs(i,1);
	for (int i=1;i<=4*n*n;i++) col1[i]=color[i];
	memset(head,0,sizeof(head));kk=0;
	for (int i=0;i<2*n;i++){
		for (int j=0;j<2*n;j++){
			for (int k=0;k<(int)G[2].size();k++){
				int tx=G[2][k].x;int ty=G[2][k].y;
				int x=up(i,tx);int y=up(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],1)/*,add(pos[y][x],pos[j][i],1)*/;
				x=up(i,tx);y=down(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],1)/*,add(pos[y][x],pos[j][i],1)*/;
				x=down(i,tx);y=up(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],1)/*,add(pos[y][x],pos[j][i],1)*/;
				x=down(i,tx);y=down(j,ty);
				if (pd(x,y)) add(pos[i][j],pos[x][y],1)/*,add(pos[y][x],pos[j][i],1)*/;
			}
		}
	}
	//cerr<<kk<<endl;
	memset(color,0,sizeof(color));
	for (int i=1;i<=4*n*n;i++) if (!color[i]) dfs(i,col1[i]);
	for (int i=1;i<=4*n*n;i++){
		if (col1[i]==1) bt1[i]=1;
		else bt2[i]=1;
	}
	for (int i=1;i<=4*n*n;i++){
		if (col2[i]==1) bt3[i]=1;
		else bt4[i]=1;
	}
	tmp1=bt1&bt3;tmp2=bt1&bt4;tmp3=bt2&bt3;tmp4=bt2&bt4;
	if ((int)tmp1.count()>=n*n) print(tmp1);
	else if ((int)tmp2.count()>=n*n) print(tmp2);
	else if ((int)tmp3.count()>=n*n) print(tmp3);
	else if ((int)tmp4.count()>=n*n) print(tmp4);
	return 0;
}

Measured memory_bytes: 591616