h, w, n = list(map(int, input().split()))

li = []

l = [w] * h

for _ in range(n):

    x, y = list(map(int, input().split()))

    li.append((x - 1, y - 1))

li.sort()

cnt = 0

ans = h

for x, y in li:

    if x - cnt == y:

        cnt += 1

    elif x - cnt > y:

        ans = min(ans, x)

print(ans)



h, w, n = list(map(int, input().split()))

l = [list(map(int, input().split())) for _ in range(n)]

l.sort(key=lambda x: (x[1], x[0]))

t = 0

a = [h + 1]

for x, y in l:

    if x > y + t:

        a.append(x)

    elif x == y + t:

        t += 1

print((min(a) - 1))

h, w, n = list(map(int, input().split()))
li = []
l = [w] * h
for _ in range(n):
    x, y = list(map(int, input().split()))
    li.append((x - 1, y - 1))
li.sort()
cnt = 0
ans = h
for x, y in li:
    if x - cnt == y:
        cnt += 1
    elif x - cnt > y:
        ans = min(ans, x)
print(ans)

h, w, n = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x: (x[1], x[0]))
t = 0
a = [h + 1]
for x, y in l:
    if x > y + t:
        a.append(x)
    elif x == y + t:
        t += 1
print((min(a) - 1))

-li = [] -l = [w] * h -for _ in range(n): -    x, y = list(map(int, input().split())) -    li.append((x - 1, y - 1)) -li.sort() -cnt = 0 -ans = h -for x, y in li: -    if x - cnt == y: -        cnt += 1 -    elif x - cnt > y: -        ans = min(ans, x) -print(ans) +l = [list(map(int, input().split())) for _ in range(n)] +l.sort(key=lambda x: (x[1], x[0])) +t = 0 +a = [h + 1] +for x, y in l: +    if x > y + t: +        a.append(x) +    elif x == y + t: +        t += 1 +print((min(a) - 1))