import bisect

import sys



a, b, q = list(map(int, input().split()))

lines = sys.stdin.readlines()

sss = list(map(int, lines[:a]))

ttt = list(map(int, lines[a:a + b]))

xxx = list(map(int, lines[a + b:]))



nearest_temples = [0] * a

nearest_shrines = [0] * b

for i, s in enumerate(sss):

    ti = bisect.bisect(ttt, s)

    nt = 10 ** 11

    if ti > 0:

        nt = min(nt, abs(s - ttt[ti - 1]))

    if ti < b:

        nt = min(nt, abs(s - ttt[ti]))

    nearest_temples[i] = nt

for i, t in enumerate(ttt):

    si = bisect.bisect(sss, t)

    ns = 10 ** 11

    if si > 0:

        ns = min(ns, abs(t - sss[si - 1]))

    if si < a:

        ns = min(ns, abs(t - sss[si]))

    nearest_shrines[i] = ns



buf = []

for x in xxx:

    si = bisect.bisect(sss, x)

    ti = bisect.bisect(ttt, x)

    ans = 10 ** 11

    if si > 0:

        ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1])

    if si < a:

        ans = min(ans, sss[si] - x + nearest_temples[si])

    if ti > 0:

        ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1])

    if ti < b:

        ans = min(ans, ttt[ti] - x + nearest_shrines[ti])

    buf.append(ans)

print(('\n'.join(map(str, buf))))

import bisect

import sys



SENTINEL = 10 ** 12



a, b, q = list(map(int, input().split()))

lines = sys.stdin.readlines()

sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]

ttt = [-SENTINEL] + list(map(int, lines[a:a + b])) + [SENTINEL]

xxx = list(map(int, lines[a + b:]))



nearest_temples = [SENTINEL] + [0] * a + [SENTINEL]

nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL]

for i, s in enumerate(sss[1:-1], start=1):

    ti = bisect.bisect(ttt, s)

    nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1])

for i, t in enumerate(ttt[1:-1], start=1):

    si = bisect.bisect(sss, t)

    nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1])



buf = []

for x in xxx:

    si = bisect.bisect(sss, x)

    ti = bisect.bisect(ttt, x)

    ans = min(x - sss[si - 1] + nearest_temples[si - 1],

              sss[si] - x + nearest_temples[si],

              x - ttt[ti - 1] + nearest_shrines[ti - 1],

              ttt[ti] - x + nearest_shrines[ti])

    buf.append(ans)

print(('\n'.join(map(str, buf))))

import bisect
import sys

a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = list(map(int, lines[:a]))
ttt = list(map(int, lines[a : a + b]))
xxx = list(map(int, lines[a + b :]))
nearest_temples = [0] * a
nearest_shrines = [0] * b
for i, s in enumerate(sss):
    ti = bisect.bisect(ttt, s)
    nt = 10**11
    if ti > 0:
        nt = min(nt, abs(s - ttt[ti - 1]))
    if ti < b:
        nt = min(nt, abs(s - ttt[ti]))
    nearest_temples[i] = nt
for i, t in enumerate(ttt):
    si = bisect.bisect(sss, t)
    ns = 10**11
    if si > 0:
        ns = min(ns, abs(t - sss[si - 1]))
    if si < a:
        ns = min(ns, abs(t - sss[si]))
    nearest_shrines[i] = ns
buf = []
for x in xxx:
    si = bisect.bisect(sss, x)
    ti = bisect.bisect(ttt, x)
    ans = 10**11
    if si > 0:
        ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1])
    if si < a:
        ans = min(ans, sss[si] - x + nearest_temples[si])
    if ti > 0:
        ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1])
    if ti < b:
        ans = min(ans, ttt[ti] - x + nearest_shrines[ti])
    buf.append(ans)
print(("\n".join(map(str, buf))))

import bisect
import sys

SENTINEL = 10**12
a, b, q = list(map(int, input().split()))
lines = sys.stdin.readlines()
sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]
ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL]
xxx = list(map(int, lines[a + b :]))
nearest_temples = [SENTINEL] + [0] * a + [SENTINEL]
nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL]
for i, s in enumerate(sss[1:-1], start=1):
    ti = bisect.bisect(ttt, s)
    nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1])
for i, t in enumerate(ttt[1:-1], start=1):
    si = bisect.bisect(sss, t)
    nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1])
buf = []
for x in xxx:
    si = bisect.bisect(sss, x)
    ti = bisect.bisect(ttt, x)
    ans = min(
        x - sss[si - 1] + nearest_temples[si - 1],
        sss[si] - x + nearest_temples[si],
        x - ttt[ti - 1] + nearest_shrines[ti - 1],
        ttt[ti] - x + nearest_shrines[ti],
    )
    buf.append(ans)
print(("\n".join(map(str, buf))))

+SENTINEL = 10**12 -sss = list(map(int, lines[:a])) -ttt = list(map(int, lines[a : a + b])) +sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL] +ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL] -nearest_temples = [0] * a -nearest_shrines = [0] * b -for i, s in enumerate(sss): +nearest_temples = [SENTINEL] + [0] * a + [SENTINEL] +nearest_shrines = [SENTINEL] + [0] * b + [SENTINEL] +for i, s in enumerate(sss[1:-1], start=1): -    nt = 10**11 -    if ti > 0: -        nt = min(nt, abs(s - ttt[ti - 1])) -    if ti < b: -        nt = min(nt, abs(s - ttt[ti])) -    nearest_temples[i] = nt -for i, t in enumerate(ttt): +    nearest_temples[i] = min(ttt[ti] - s, s - ttt[ti - 1]) +for i, t in enumerate(ttt[1:-1], start=1): -    ns = 10**11 -    if si > 0: -        ns = min(ns, abs(t - sss[si - 1])) -    if si < a: -        ns = min(ns, abs(t - sss[si])) -    nearest_shrines[i] = ns +    nearest_shrines[i] = min(sss[si] - t, t - sss[si - 1]) -    ans = 10**11 -    if si > 0: -        ans = min(ans, x - sss[si - 1] + nearest_temples[si - 1]) -    if si < a: -        ans = min(ans, sss[si] - x + nearest_temples[si]) -    if ti > 0: -        ans = min(ans, x - ttt[ti - 1] + nearest_shrines[ti - 1]) -    if ti < b: -        ans = min(ans, ttt[ti] - x + nearest_shrines[ti]) +    ans = min( +        x - sss[si - 1] + nearest_temples[si - 1], +        sss[si] - x + nearest_temples[si], +        x - ttt[ti - 1] + nearest_shrines[ti - 1], +        ttt[ti] - x + nearest_shrines[ti], +    )