#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, D1, D2;

vector<pii> solve(int n1, int n2, int d1, int d2) {
    vector<pii> ret;
    if (!n1 || !n2) return ret;
    if (n1 == 1 && n2 == 1) {
        ret.push_back(pii(0, 0));
        return ret;
    }
    if (d1 % 4 != 0) swap(d1, d2);
    vector<pii> v;

    if (d1 % 4 != 0) {
        if (d1 % 4 == 3 && d2 % 4 == 3) {
            F0(i, n1) F0(j, n2) ret.push_back(pii(i, j));
        } else
        if (d1 % 4 != 3 && d2 % 4 != 3) {
            F0(i, n1) F0(j, n2) if ((i%2) == 0 && (j%2) == 0) ret.push_back(pii(i, j));
        } else {
            if (d1 % 4 == 3) swap(d1, d2);
            if (d1 % 4 == 1) {
                F0(i, n1) F0(j, n2) if ((i%2) == (j%2)) ret.push_back(pii(i, j));
            } else {
                F0(i, n1) F0(j, n2) if (i%2==0) ret.push_back(pii(i, j));
            }
        }
        return ret;
    }

    if (d2 % 4 == 0) {
        v = solve((n1 + 1) / 2, (n2 + 1) / 2, d1 / 4, d2 / 4);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second));
        v = solve((n1 + 1) / 2, (n2) / 2, d1 / 4, d2 / 4);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second + 1));
        v = solve((n1) / 2, (n2 + 1) / 2, d1 / 4, d2 / 4);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second));
        v = solve((n1) / 2, (n2) / 2, d1 / 4, d2 / 4);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second + 1));
    } else if (d2 % 4 == 1) {
        v = solve((n1 + 1) / 2, (n2 + 1) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second));
        v = solve((n1) / 2, (n2) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second + 1));
    } else if (d2 % 4 == 2) {
        v = solve((n1 + 1) / 2, (n2 + 1) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second));
        v = solve((n1) / 2, (n2 + 1) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second));
    } else if (d2 % 4 == 3) {
        v = solve((n1 + 1) / 2, (n2 + 1) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second));
        v = solve((n1 + 1) / 2, (n2) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first, 2 * p.second + 1));
        v = solve((n1) / 2, (n2 + 1) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second));
        v = solve((n1) / 2, (n2) / 2, d1 / 4, 3);
        for (pii p : v) ret.push_back(pii(2 * p.first + 1, 2 * p.second + 1));
    }
    return ret;
}

void solve() {
    vector<pii> v = solve(2 * n, 2 * n, D1, D2);

    v.resize(n * n);
    for (pii p : v) printf("%d %d\n", p.first, p.second);
}

int main() {
    //freopen("x.in", "r", stdin);

    while (cin >> n >> D1 >> D2) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 2536