#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int dx[4] = {-1, 1, -1, 1};
int dy[4] = {-1, -1, 1, 1};
int da[4] = {0, 1, 0, 1};
int db[4] = {0, 0, 1, 1};

bool isSquare(int n) {
    int m = floor(sqrt(n));
    return (n == m * m);
}

int N;
int grapha[600][600];
int graphb[600][600];
vector<int> samex[4], samey[4];
vector<pii> D1pair, D2pair;

void dfs (pii p, int gnum, int color) {
    int px = p.first;
    int py = p.second;
    if (gnum == 0) {
        int num = D1pair.size();
        for (int i = 0; i < num; i++) {
            int mx = D1pair[i].first;
            int my = D1pair[i].second;
            for (int l = 0; l < 4; l++) {
                int x = px + dx[l] * mx;
                int y = py + dy[l] * my;
                if (x >= 0 && x < 2 * N && y >= 0 && y < 2 * N && grapha[x][y] == intmax) {
                    grapha[x][y] = (color + 1) % 2;
                    dfs(pii(x, y), 0, (color + 1) % 2);
                }
            }
        }
    } else {
        int num = D2pair.size();
        for (int i = 0; i < num; i++) {
            int mx = D2pair[i].first;
            int my = D2pair[i].second;
            for (int l = 0; l < 4; l++) {
                int x = px + dx[l] * mx;
                int y = py + dy[l] * my;
                if (x >= 0 && x < 2 * N && y >= 0 && y < 2 * N && graphb[x][y] == intmax) {
                    graphb[x][y] = (color + 1) % 2;
                    dfs(pii(x, y), 1, (color + 1) % 2);
                }
            }
        }
    }
}

int main() {
    int D1, D2;
    cin >> N >> D1 >> D2;
    for (int i = 0; i < 2 * N; i++) {
        fill(grapha[i], grapha[i] + 2 * N, intmax);
        fill(graphb[i], graphb[i] + 2 * N, intmax);
    }
    for (int i = 0; i <= sqrt(D1); i++) {
        if (isSquare(D1 - i * i)) {
            D1pair.push_back(pii(i, floor(sqrt(D1 - i * i))));
        }
    }
    for (int i = 0; i <= sqrt(D2); i++) {
        if (isSquare(D2 - i * i)) {
            D2pair.push_back(pii(i, floor(sqrt(D2 - i * i))));
        }
    }
    // for (int i = 0; i < D1pair.size(); i++) {
    //     cout << D1pair[i].first << " " << D1pair[i].second << endl;
    // }
    // cout << "aaaaaaaaaaaaaaaaa" << endl;
    // for (int i = 0; i < D2pair.size(); i++) {
    //     cout << D2pair[i].first << " " << D2pair[i].second << endl;
    // }
    // cout << "bbbbbbbbbbbbbbbbb" << endl;
    for (int i = 0; i < 2 * N; i++) {
        for (int j = 0; j < 2 * N; j++) {
            if (grapha[i][j] == intmax) {
                grapha[i][j] = 0;
                dfs(pii(i, j), 0, 0);
            }
            if (graphb[i][j] == intmax) {
                graphb[i][j] = 0;
                dfs(pii(i, j), 1, 0);
            }
        }
    }
    // for (int i = 0; i < 2 * N; i++) {
    //     for (int j = 0; j < 2 * N; j++) {
    //         cout << grapha[i][j] << " " << graphb[i][j] << endl;
    //     }
    // }
    // cout << "cccccccccccccccccc" << endl;
    for (int i = 0; i < 2 * N; i++) {
        for (int j = 0; j < 2 * N; j++) {
            for (int k = 0; k < 4; k++) {
                if (grapha[i][j] == da[k] && graphb[i][j] == db[k]) {
                    samex[k].push_back(i);
                    samey[k].push_back(j);
                }
            }
        }
    }
    for (int i = 0; i < 4; i++) {
        // cout << samex[i].size() << endl;
        // cout << grapha[0][0] << " " << graphb[0][0] << endl;
        // cout << "ddddddddd" << endl;
        if (samex[i].size() >= N * N) {
            for (int j = 0; j < N * N; j++) {
                cout << samex[i][j] << " " << samey[i][j] << endl;
            }
            break;
        }
    }
}


Measured memory_bytes: 34936