H, W, N = list(map(int, input().split()))



Y = [W+100]*(H+1)

P = [[] for i in range(W+1)]

for i in range(N):

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

    if x < y:

        continue

    Y[x-y] = min(Y[x-y], y-1)

    P[y-1].append(x-1)

base = 0

ans = H

for y in range(W):

    while Y[base] == y:

        base += 1

    xmin = y + base

    for x in P[y]:

        if xmin <= x:

            ans = min(x, ans)

print(ans)
readline = open(0).readline

write = open(1, 'w').write



H, W, N = list(map(int, readline().split()))



Y = [W+1]*(H+1)

P = [[] for i in range(W+1)]

for i in range(N):

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

    if x < y:

        continue

    Y[x-y] = min(Y[x-y], y-1)

    P[y-1].append(x-1)

base = 0

ans = H

for y in range(W):

    while Y[base] == y:

        base += 1

    xmin = y + base

    for x in P[y]:

        if xmin <= x:

            ans = min(x, ans)

write("%d\n" % ans)
H, W, N = list(map(int, input().split()))
Y = [W + 100] * (H + 1)
P = [[] for i in range(W + 1)]
for i in range(N):
    x, y = list(map(int, input().split()))
    if x < y:
        continue
    Y[x - y] = min(Y[x - y], y - 1)
    P[y - 1].append(x - 1)
base = 0
ans = H
for y in range(W):
    while Y[base] == y:
        base += 1
    xmin = y + base
    for x in P[y]:
        if xmin <= x:
            ans = min(x, ans)
print(ans)

readline = open(0).readline
write = open(1, "w").write
H, W, N = list(map(int, readline().split()))
Y = [W + 1] * (H + 1)
P = [[] for i in range(W + 1)]
for i in range(N):
    x, y = list(map(int, readline().split()))
    if x < y:
        continue
    Y[x - y] = min(Y[x - y], y - 1)
    P[y - 1].append(x - 1)
base = 0
ans = H
for y in range(W):
    while Y[base] == y:
        base += 1
    xmin = y + base
    for x in P[y]:
        if xmin <= x:
            ans = min(x, ans)
write("%d\n" % ans)

-H, W, N = list(map(int, input().split())) -Y = [W + 100] * (H + 1) +readline = open(0).readline +write = open(1, "w").write +H, W, N = list(map(int, readline().split())) +Y = [W + 1] * (H + 1) -    x, y = list(map(int, input().split())) +    x, y = list(map(int, readline().split())) -print(ans) +write("%d\n" % ans)