n, m, c = map(int, input().split())

schools = [0] * (m + 1)
yes = 0
no = 0
for _ in range(n):
  a, b = map(int, input().split())
  if schools[a] < c:
    schools[a] += 1
    yes += 1
  elif schools[b] < c:
    schools[b] += 1
    no += 1
print(yes, no)
