#!/usr/bin/python3

N, K, M = [ int(_) for _ in input().split() ]
assert N == 5 and K == 4

G = [ [ False for b in range(N) ] for a in range(N) ]

for m in range(M):
    x, y = [ int(_) for _ in input().split() ]
    G[x][y] = True
    G[y][x] = True

print(10 - M)
for a in range(N):
    for b in range(a+1, N):
        if not G[a][b]:
            print(a, b)

