#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
#include<tr1/unordered_map>
#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];
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;//cerr<<u<<"color:"<<col<<endl; 
	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++){
		//cerr<<i<<endl;
		if (xx[i]) printf("%d %d\n",p[i].x,p[i].y),tot++;
		//cerr<<tot<<endl;
		if (tot==n*n) return;
	}
}
inline int pd(int x,int y){return (x<2*n&&x>=0&&y<2*n&&y>=0);}
inline void debug(){
	for (int i=1;i<=4*n*n;i++)
		printf("%d %d %d\n",p[i].x,p[i].y,col1[i]);
	
	int u=1;printf("sta %d %d\n",p[u].x,p[u].y);
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		printf("wtf %d %d\n",p[v].x,p[v].y);
	}
}
int main(){
	//freopen("get.out","w",stdout);
	scanf("%d%d%d",&n,&d1,&d2);
	//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)*/;
			}
		}
	}//int u=1;for (int i=head[u];i;i=e[i].nxt) printf("shiiit%d\n",e[i].to);
	//for (int i=1;i<=n*n*4;i++) mp[i].clear();无用了 
	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];
	//debug();
	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++){
				//cerr<<"now:"<<kk<<endl;
				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)*/;
				//cerr<<"now1:"<<kk<<endl;
				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)*/;
				//cerr<<"now2:"<<kk<<endl;
				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)*/;
				//cerr<<"now3:"<<kk<<endl;
				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<<"now4:"<<kk<<endl;
			}
			//if (i==0) cerr<<kk<<endl;
		}
		//cerr<<kk<<endl;
	}
	memset(color,0,sizeof(color));
	//for (int i=1;i<=4*n*n;i++) printf("%d ",col1[i]);puts("");
	for (int i=1;i<=4*n*n;i++) if (!color[i]) /*printf("start:%d\n",i),*/dfs(i,col1[i]);
	//for (int i=1;i<=4*n*n;i++) col2[i]=color[i];
	//for (int i=1;i<=4*n*n;i++) printf("%d ",col2[i]);puts("");
	//printf("%d %d %d %d\n",p[1].x,p[1].y,p[3].x,p[3].y);
	//int u=1;for (int i=head[u];i;i=e[i].nxt) printf("shiiit%d\n",e[i].to); 
	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);
	//else while (1);
	//cerr<<kk<<endl;
	//cerr<<getid(1,0)<<endl;
	return 0;
}

Measured memory_bytes: 627456