#include <iostream>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cstring>
#include <functional>
#include <vector>
#include <list>
#include <algorithm>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9;

int sum_base(int n, int b = 10) {
  int s = 0;
  while (n) { s += n % b; n /= b; }
  return s;
}

void solve_a() {
  int n; cin >> n;
  int r = inf;
  fore(a, 1, n - 1) uin(r, sum_base(a) + sum_base(n - a));
  cout << r << endl;
}

void solve_b() {
  int n; cin >> n;
  i64 a, b; cin >> a >> b;
  i64 k; cin >> k;
  const int mod = 998244353;
  auto mul = [] (int a, int b) {
    return a * 1ll * b % mod;
  };
  auto sum = [] (int a, int b) {
    if ((a += b) >= mod) a -= mod;
    return a;
  };
  auto power = [&] (int a, i64 n) {
    int r = 1; while (n) {
      if (n&1) r = mul(r, a);
      if (n/=2) a = mul(a, a);
    } return r;
  };
  vi ff(n + 1, 1);
  vi fi(n + 1, 1);
  fore(i, 1, n) ff[i] = mul(ff[i-1], i);
  fi[n] = power(ff[n], mod - 2);
  for (int i = n - 1; i >= 1; --i) fi[i] = mul(fi[i + 1], i + 1);
  auto get3 = [&] (int n, int i, int j, int k) {
    return mul(mul(mul(ff[n], fi[i]), fi[j]), fi[k]);
  };
  auto get2 = [&] (int n, int i, int j) {
    return mul(mul(ff[n], fi[i]), fi[j]);
  };
  vi cnk(n + 1, 1);
  fore(i, 1, n) cnk[i] = sum(cnk[i-1], get2(n, i, n - i));
  int r = 0;
  fore(i, 0, n) {
    i64 sk = k - a * i;
    if (sk >= 0 && sk % b == 0) {
      i64 j = sk / b;
      if (j <= n) {
        r = sum(r, mul(get2(n, i, n - i), get2(n, j, n - j)));
      }
    }
  }
  cout << r << endl;
}

vvi a, u;
vpi zz;
int n;

bool ok2(int i, int j) {
  return 0 <= i && i < 2 * n && 0 <= j && j < 2 * n;
};

bool dfs(int ij, char c) {
  int i = ij / (2 * n);
  int j = ij % (2 * n);
  if (!u[i][j]) return true;
  if (a[i][j]) return a[i][j] == c;
  a[i][j] = c;
  forn(t, zz.size()) {
    int ni = i + zz[t].fi, nj = j + zz[t].se;
    if (!ok2(ni, nj)) continue;
    if (!dfs(ni * (2 * n) + nj, 3 - c)) return false;
  }
  return true;
};

bool dfs(int i, int j, int c) {
  return dfs(i * 2 * n + j, c);
}

bool solve_d2(int n, int d0, int d1) {
  ::n = n;
  vpi z0, z1;
  fore(i, -2 * n + 1, 2 * n - 1) {
    fore(j, -2 * n + 1, 2 * n - 1) {
      if (i * i + j * j == d0) z0.eb(i, j);
      if (i * i + j * j == d1) z1.eb(i, j);
    }
  }
  a = vvi(2 * n, vi(2 * n, 0));
  u = vvi(2 * n, vi(2 * n, 1));
  zz = z0;
  forn(i, 2 * n) forn(j, 2 * n) if (a[i][j] == 0) dfs(i, j, 1);
  vi c0(2, 0);
  forn(i, 2 * n) forn(j, 2 * n) c0[a[i][j] - 1] += 1;
  int c0d = c0[0] > c0[1] ? 1 : 2;
  forn(i, 2 * n) forn(j, 2 * n) if (a[i][j] != c0d) u[i][j] = 0;
  forn(i, 2 * n) forn(j, 2 * n) a[i][j] = 0;
  zz = z1;
  forn(i, 2 * n) forn(j, 2 * n) if (u[i][j] && a[i][j] == 0) dfs(i, j, 1);
  vi c1(2, 0);
  forn(i, 2 * n) forn(j, 2 * n) if (u[i][j]) c1[a[i][j] - 1] += 1;
  int c1d = c1[0] > c1[1] ? 1 : 2;
  vpi r;
  forn(i, 2 * n) forn(j, 2 * n) if (u[i][j] && a[i][j] == c1d) r.eb(i, j);
  assert(r.size() >= n * n);
  // if (r.size() < n * n) return false;
  r.resize(n * n);
  for (auto e: r) cout << e.fi << ' ' << e.se << endl;
  return true;
}

bool solve_d(int n, int d0, int d1) {
  vpi z;
  fore(i, -2 * n + 1, 2 * n - 1) {
    fore(j, -2 * n + 1, 2 * n - 1) {
      if (i * i + j * j == d0 || i * i + j * j == d1) {
        z.eb(i, j);
      }
    }
  }
  auto ok2 = [&] (int i, int j) {
    return 0 <= i && i < 2 * n && 0 <= j && j < 2 * n;
  };
  vpi order;
  fore(i, 0, 2 * n - 1) {
    fore(j, 0, 2 * n - 1) {
      order.eb(i, j);
    }
  }
  do {
    vvi a(2 * n, vi(2 * n, 0));
    vpi r;
    for (auto eo: order) {
      int i = eo.fi, j = eo.se;
      if (r.size() >= n * n) break;
      bool ok = true;
      for(auto e: z) {
        if (ok2(i + e.fi, j + e.se) && a[i + e.fi][j + e.se]) {
          ok = false; break;
        }
      }
      if (ok) {
        a[i][j] = 1;
        r.eb(i, j);
      }
    }
    if (r.size() == n * n) {
      // for (auto e: r) cout << e.fi << ' ' << e.se << endl;
      return true;
    }
    random_shuffle(all(order));
  } while (true);
  return false;
}

int main() {
#ifdef HOME
  freopen("input.txt", "rt", stdin);
#endif
  int n, d0, d1; 
  n = 300; d0 = 2; d1 = 2;
  cin >> n >> d0 >> d1; 
  solve_d2(n, d0, d1); return 0;

  for(int n: {2, 3, 4, 5, 100, 200, 300}) {
    for(int d0: {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,36,49,64,81,100}) {
      for(int d1: {1,2,3,4,5,6,7,8,9,10,16,25,36,49,64,81,100}) {
        if (d0 <= d1) {
          if (!solve_d2(n, d0, d1)) {
            cout << n << ' ' << d0 << ' ' << d1 << endl;
            return 1;
          }
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 23948