#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdio>
#define N 604
using namespace std;

int n, m, a[N][N], num[6];

inline void work(int d, int op) {
    int c = 0;
    while (d % 4 == 0) d >>= 2, ++c;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) {
            if ((d & 1) == 0) a[i][j] = op * a[i][j] + ((i >> c) & 1);
            else a[i][j] = op * a[i][j] + (((i >> c) + (j >> c)) & 1);
        }
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    int d1, d2;
    cin >> n >> d1 >> d2, m = n * n, n <<= 1;
    work(d1, 0), work(d2, 2);

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            ++num[a[i][j]];

    int id = 0;
    while (num[id] < m) ++id;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if (m && a[i][j] == id) printf("%d %d\n", i, j), --m;

    return 0;
}
