#include <iostream>

const int N = 600 + 7;

int n;
int f[N][N], g[4], h;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n), n <<= 1;
	for (int t = 1, k, d; t <= 2; ++t) {
		scanf("%d", &d),
		k = 1 << __builtin_ctz(d) / 2;
		d = d / k / k % 4 == 1;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				f[i][j] |= (i / k + j / k * d) & 1 ? t : 0;
	}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			++g[f[i][j]];
	for (int i = 1; i <= 3; ++i)
		h = g[i] > g[h] ? i : h;
	for (int i = 0, k = n * n / 4; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (f[i][j] == h && k) --k, printf("%d %d\n", i, j);

	return 0;
}
