from math import sqrt

from itertools import product



import numpy as np



def helper(N,D):

  if D%2 == 1:

    grid = np.zeros((N,N),dtype=bool)

    grid[::2,:] = True

    grid[:,1::2] = ~grid[:,1::2]

  elif D%4 == 2:

    grid = np.zeros((N,N),dtype=bool)

    grid[::2,:] = True

  else:

    M = (N-1)//2+1

    D //= 4

    g = helper(M, D)

    grid = np.zeros((2*M,2*M),dtype=bool)

    grid[::2,::2] = g

    grid[1::2,::2] = g

    grid[::2,1::2] = g

    grid[1::2,1::2] = g

    grid = grid[:N,:N]

  return grid





N,D1,D2 = list(map(int,input().split()))

M = N*2

g1 = helper(N*2,D1)

g2 = helper(N*2,D2)

ans = g1&g2





for x,y in np.transpose(np.nonzero(ans))[:N*N]:

  print((x,y))

from math import sqrt

from itertools import product



import numpy as np



def judge(D):

  n = 1

  while D%4==0:

    n *= 2

    D //= 4



  def h1(x,y):

    return ~(x//n+y//n)%2

  def h2(x,y):

    return ~(x//n)%2



  return h1 if D%2==1 else h2



N,D1,D2 = list(map(int,input().split()))

j1,j2 = judge(D1),judge(D2)

cnt = 0

for x,y in product(list(range(N*2)),repeat=2):

  if j1(x,y) and j2(x,y):

    print((x,y))

    cnt += 1

    if cnt >= N*N:

      break

from math import sqrt
from itertools import product
import numpy as np


def helper(N, D):
    if D % 2 == 1:
        grid = np.zeros((N, N), dtype=bool)
        grid[::2, :] = True
        grid[:, 1::2] = ~grid[:, 1::2]
    elif D % 4 == 2:
        grid = np.zeros((N, N), dtype=bool)
        grid[::2, :] = True
    else:
        M = (N - 1) // 2 + 1
        D //= 4
        g = helper(M, D)
        grid = np.zeros((2 * M, 2 * M), dtype=bool)
        grid[::2, ::2] = g
        grid[1::2, ::2] = g
        grid[::2, 1::2] = g
        grid[1::2, 1::2] = g
        grid = grid[:N, :N]
    return grid


N, D1, D2 = list(map(int, input().split()))
M = N * 2
g1 = helper(N * 2, D1)
g2 = helper(N * 2, D2)
ans = g1 & g2
for x, y in np.transpose(np.nonzero(ans))[: N * N]:
    print((x, y))

from math import sqrt
from itertools import product
import numpy as np


def judge(D):
    n = 1
    while D % 4 == 0:
        n *= 2
        D //= 4

    def h1(x, y):
        return ~(x // n + y // n) % 2

    def h2(x, y):
        return ~(x // n) % 2

    return h1 if D % 2 == 1 else h2


N, D1, D2 = list(map(int, input().split()))
j1, j2 = judge(D1), judge(D2)
cnt = 0
for x, y in product(list(range(N * 2)), repeat=2):
    if j1(x, y) and j2(x, y):
        print((x, y))
        cnt += 1
        if cnt >= N * N:
            break

-def helper(N, D): -    if D % 2 == 1: -        grid = np.zeros((N, N), dtype=bool) -        grid[::2, :] = True -        grid[:, 1::2] = ~grid[:, 1::2] -    elif D % 4 == 2: -        grid = np.zeros((N, N), dtype=bool) -        grid[::2, :] = True -    else: -        M = (N - 1) // 2 + 1 +def judge(D): +    n = 1 +    while D % 4 == 0: +        n *= 2 -        g = helper(M, D) -        grid = np.zeros((2 * M, 2 * M), dtype=bool) -        grid[::2, ::2] = g -        grid[1::2, ::2] = g -        grid[::2, 1::2] = g -        grid[1::2, 1::2] = g -        grid = grid[:N, :N] -    return grid + +    def h1(x, y): +        return ~(x // n + y // n) % 2 + +    def h2(x, y): +        return ~(x // n) % 2 + +    return h1 if D % 2 == 1 else h2 -M = N * 2 -g1 = helper(N * 2, D1) -g2 = helper(N * 2, D2) -ans = g1 & g2 -for x, y in np.transpose(np.nonzero(ans))[: N * N]: -    print((x, y)) +j1, j2 = judge(D1), judge(D2) +cnt = 0 +for x, y in product(list(range(N * 2)), repeat=2): +    if j1(x, y) and j2(x, y): +        print((x, y)) +        cnt += 1 +        if cnt >= N * N: +            break