#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
vector <pair <int, int>> work(vector <pair <int, int>> input, int a) {
	if (input.size() <= 1) return input;
	vector <pair <int, int>> ans;
	if (a % 2) {
		int cnt[2] = {0, 0};
		for (auto x : input) cnt[(x.first + x.second) & 1]++;
		int home = cnt[0] > cnt[1] ? 0 : 1;
		for (auto x : input) if ((x.first + x.second) % 2 == home) ans.push_back(x);
		return ans;
	}
	if (a % 4) {
		int cnt[2] = {0, 0};
		for (auto x : input) cnt[x.first & 1]++;
		int home = cnt[0] > cnt[1] ? 0 : 1;
		for (auto x : input) if (x.first % 2 == home) ans.push_back(x);
		return ans;
	}
	vector <pair <int, int>> nxt, tmp;
	nxt.clear(); for (auto x : input) if (x.first % 2 == 0 && x.second % 2 == 0) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4); for (auto x : tmp) ans.emplace_back(x.first * 2, x.second * 2);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 0 && x.second % 2 == 1) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4); for (auto x : tmp) ans.emplace_back(x.first * 2, x.second * 2 + 1);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 1 && x.second % 2 == 0) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4); for (auto x : tmp) ans.emplace_back(x.first * 2 + 1, x.second * 2);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 1 && x.second % 2 == 1) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4); for (auto x : tmp) ans.emplace_back(x.first * 2 + 1, x.second * 2 + 1);
	return ans;
}
vector <pair <int, int>> work(vector <pair <int, int>> input, int a, int b) {
	if (input.size() <= 1) return input;
	vector <pair <int, int>> ans;
	if (a % 2 && b % 2) {
		int cnt[2] = {0, 0};
		for (auto x : input) cnt[(x.first + x.second) & 1]++;
		int home = cnt[0] > cnt[1] ? 0 : 1;
		for (auto x : input) if ((x.first + x.second) % 2 == home) ans.push_back(x);
		return ans;
	}
	if (a % 2) swap(a, b);
	if (b % 2) {
		vector <pair <int, int>> nxt1, nxt2;
		for (auto x : input) {
			if ((x.first + x.second) & 1) nxt1.push_back(x);
			else nxt2.push_back(x);
		}
		vector <pair <int, int>> tmp1 = work(nxt1, a);
		vector <pair <int, int>> tmp2 = work(nxt2, a);
		if (tmp1.size() > tmp2.size()) return tmp1;
		else return tmp2;
	}
	if (a % 4) swap(a, b);
	if (b % 4) {
		vector <pair <int, int>> nxt1, nxt2;
		for (auto x : input) {
			if (x.first & 1) nxt1.push_back(x);
			else nxt2.push_back(x);
		}
		vector <pair <int, int>> tmp1 = work(nxt1, a);
		vector <pair <int, int>> tmp2 = work(nxt2, a);
		if (tmp1.size() > tmp2.size()) return tmp1;
		else return tmp2;
	}
	vector <pair <int, int>> nxt, tmp;
	nxt.clear(); for (auto x : input) if (x.first % 2 == 0 && x.second % 2 == 0) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4, b / 4); for (auto x : tmp) ans.emplace_back(x.first * 2, x.second * 2);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 0 && x.second % 2 == 1) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4, b / 4); for (auto x : tmp) ans.emplace_back(x.first * 2, x.second * 2 + 1);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 1 && x.second % 2 == 0) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4, b / 4); for (auto x : tmp) ans.emplace_back(x.first * 2 + 1, x.second * 2);
	nxt.clear(); for (auto x : input) if (x.first % 2 == 1 && x.second % 2 == 1) nxt.emplace_back(x.first / 2, x.second / 2);
	tmp = work(nxt, a / 4, b / 4); for (auto x : tmp) ans.emplace_back(x.first * 2 + 1, x.second * 2 + 1);
	return ans;
}
int main() {
	int n, a, b; read(n), read(a), read(b);
	vector <pair <int, int>> input;
	for (int i = 0; i < n * 2; i++)
	for (int j = 0; j < n * 2; j++)
		input.emplace_back(i, j);
	vector <pair <int, int>> res = work(input, a, b); int cnt = 0;
	for (auto x : res) if (++cnt <= n * n) printf("%d %d\n", x.first, x.second);
	return 0;
}

Measured memory_bytes: 16620