#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	ll n,d1,d2;cin >> n >> d1 >> d2;
	
	vector<pair<ll,ll>> e1;
	vector<pair<ll,ll>> e2;
	
	REP(i,2*n){
		REP(j,2*n){
			if(i * i + j * j == d1){
				e1.PB(MP(i,j));
				e1.PB(MP(-i,j));
			}
			if(i * i + j * j == d2){
				e2.PB(MP(i,j));
				e2.PB(MP(-i,j));
			}
		}
	}
	
	DBG(cout << "PATHA" << endl;)
	
	vector<vector<int>> v1(4*n*n);
	vector<vector<int>> v2(4*n*n);
	
	REP(i,2*n){
		REP(j,2*n){
			int now = i*2*n + j;
			REP(k,e1.size()){
				int y = i + e1[k].FI;
				int x = j + e1[k].SE;
				if(y >= 0 && y < 2*n && x >= 0 && x < 2*n){
					int aite = y*2*n + x;
					v1[now].PB(aite);
					v1[aite].PB(now);
				}
			}
			REP(k,e2.size()){
				int y = i + e2[k].FI;
				int x = j + e2[k].SE;
				if(y >= 0 && y < 2*n && x >= 0 && x < 2*n){
					int aite = y*2*n + x;
					v2[now].PB(aite);
					v2[aite].PB(now);
				}
			}
		}
	}
	
	DBG(cout << "PATHB" << endl;)
	
	vector<int> state1(4*n*n);
	vector<int> state2(4*n*n);
	int cou1[2] = {};
	int cou2[2] = {};
	
	REP(i,4*n*n){
		if(state1[i] == 0 && v1[i].size() > 0){
			DBG(cout << " A " << i << endl;)
			queue<pair<int,int>> q;
			q.push(MP(i,1));
			while(!q.empty()){
				auto now = q.front();q.pop();
				int node = now.FI;
				int color = now.SE;
				DBG(cout << "   A   " << node << ' ' << endl;)
				if(state1[node] != 0)continue;
				state1[node] = color;
				cou1[(color + 1) / 2]++;
				REP(j,v1[node].size()){
					int aite = v1[node][j];
					if(state1[aite] == 0){
						q.push(MP(aite,-color));
					}
				}
			}
		}
	}
			
	REP(i,4*n*n){
		if(state2[i] == 0 && v2[i].size() > 0){
			DBG(cout << " B " << i << endl;)
			queue<pair<int,int>> q;
			q.push(MP(i,1));
			while(!q.empty()){
				auto now = q.front();q.pop();
				int node = now.FI;
				int color = now.SE;
				DBG(cout << "   B   " << node << ' ' << endl;)
				if(state2[node] != 0)continue;
				state2[node] = color;
				cou2[(color + 1)/2]++;
				REP(j,v2[node].size()){
					int aite = v2[node][j];
					if(state2[aite] == 0){
						q.push(MP(aite,-color));
					}
				}
			}
		}
	}
	
	DBG(cout << "PATHC" << endl;)
	
	DBG(
	REP(i,2*n){
		REP(j,2*n){
			cout <<  setw(2) << right << state1[i*2*n+j] << ' ';
		}
		cout << endl;
	}
	cout << endl << endl;
	REP(i,2*n){
		REP(j,2*n){
			cout <<  setw(2) << right << state2[i*2*n+j] << ' ';
		}
		cout << endl;
	}
	)
	
	int A,B;
	if(cou1[0] > cou1[1])A = -1;
	else A = 1;	
	if(cou2[0] > cou2[1])B = -1;
	else B = 1;
	
	int ret = 0;
	
	REP(i,2*n){
		REP(j,2*n){
			int now = i*2*n + j;
			if((state1[now] == 0 || state1[now] == A) &&
			   (state2[now] == 0 || state2[now] == B)){
				   cout << i << ' ' << j << endl;
				   ret++;
				   if(ret == n*n)return 0;
			   }
		}
	}
				
	exit(1);
	
	return 0;
}

Measured memory_bytes: 99072