from bisect import bisect_left

INF = 10 ** 11

a, b, q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(a)] + [INF]
t = [-INF] + [int(input()) for _ in range(b)] + [INF]
x = [int(input()) for _ in range(q)]

for e in x:
    si = bisect_left(s, e)
    ti = bisect_left(t, e)
    sl, sr = s[si-1], s[si]
    tl, tr = t[ti-1], t[ti]

    ans = INF
    ans = min(ans, e - min(sl, tl))
    ans = min(ans, max(sr, tr) - e)
    ans = min(ans, e - sl + tr - sl)
    ans = min(ans, e - tl + sr - tl)
    ans = min(ans, sr - e + sr - tl)
    ans = min(ans, tr - e + tr - sl)

    print(ans) from bisect import bisect_left INF = 10 ** 11 INF 10 ** 11 10 11 a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input s = [-INF] + [int(input()) for _ in range(a)] + [INF] s [-INF] + [int(input()) for _ in range(a)] + [INF] [-INF] + [int(input()) for _ in range(a)] [-INF] -INF INF [int(input()) for _ in range(a)] [INF] INF int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input t = [-INF] + [int(input()) for _ in range(b)] + [INF] t [-INF] + [int(input()) for _ in range(b)] + [INF] [-INF] + [int(input()) for _ in range(b)] [-INF] -INF INF [int(input()) for _ in range(b)] [INF] INF int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input x = [int(input()) for _ in range(q)] x [int(input()) for _ in range(q)] for e in x:
    si = bisect_left(s, e)
    ti = bisect_left(t, e)
    sl, sr = s[si-1], s[si]
    tl, tr = t[ti-1], t[ti]

    ans = INF
    ans = min(ans, e - min(sl, tl))
    ans = min(ans, max(sr, tr) - e)
    ans = min(ans, e - sl + tr - sl)
    ans = min(ans, e - tl + sr - tl)
    ans = min(ans, sr - e + sr - tl)
    ans = min(ans, tr - e + tr - sl)

    print(ans) e x si = bisect_left(s, e) si bisect_left(s, e) bisect_left s e ti = bisect_left(t, e) ti bisect_left(t, e) bisect_left t e sl, sr = s[si-1], s[si] sl s[si-1] s si-1 si 1 sr s[si] s si tl, tr = t[ti-1], t[ti] tl t[ti-1] t ti-1 ti 1 tr t[ti] t ti ans = INF ans INF ans = min(ans, e - min(sl, tl)) ans min(ans, e - min(sl, tl)) min ans e - min(sl, tl) e min(sl, tl) min sl tl ans = min(ans, max(sr, tr) - e) ans min(ans, max(sr, tr) - e) min ans max(sr, tr) - e max(sr, tr) max sr tr e ans = min(ans, e - sl + tr - sl) ans min(ans, e - sl + tr - sl) min ans e - sl + tr - sl e - sl + tr e - sl e sl tr sl ans = min(ans, e - tl + sr - tl) ans min(ans, e - tl + sr - tl) min ans e - tl + sr - tl e - tl + sr e - tl e tl sr tl ans = min(ans, sr - e + sr - tl) ans min(ans, sr - e + sr - tl) min ans sr - e + sr - tl sr - e + sr sr - e sr e sr tl ans = min(ans, tr - e + tr - sl) ans min(ans, tr - e + tr - sl) min ans tr - e + tr - sl tr - e + tr tr - e tr e tr sl print(ans) print ans INF = 10 ** 11 10 ** 11 INF q = map(int, input().split()) map(int, input().split()) q tl, tr = t[ti-1], t[ti] t[ti-1] tl ans = min(ans, sr - e + sr - tl) min(ans, sr - e + sr - tl) ans sl, sr = s[si-1], s[si] s[si-1] sl a, b, q = map(int, input().split()) map(int, input().split()) a tr = t[ti-1], t[ti] t[ti] tr ans = min(ans, e - tl + sr - tl) min(ans, e - tl + sr - tl) ans ans = min(ans, e - min(sl, tl)) min(ans, e - min(sl, tl)) ans ans = min(ans, max(sr, tr) - e) min(ans, max(sr, tr) - e) ans x = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] x t = [-INF] + [int(input()) for _ in range(b)] + [INF] [-INF] + [int(input()) for _ in range(b)] + [INF] t s = [-INF] + [int(input()) for _ in range(a)] + [INF] [-INF] + [int(input()) for _ in range(a)] + [INF] s ti = bisect_left(t, e) bisect_left(t, e) ti sr = s[si-1], s[si] s[si] sr ans = INF INF ans ans = min(ans, e - sl + tr - sl) min(ans, e - sl + tr - sl) ans si = bisect_left(s, e) bisect_left(s, e) si ans = min(ans, tr - e + tr - sl) min(ans, tr - e + tr - sl) ans b, q = map(int, input().split()) map(int, input().split()) b
from bisect import bisect_left

INF = 10 ** 11

a, b, q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(a)] + [INF]
t = [-INF] + [int(input()) for _ in range(b)] + [INF]
x = [int(input()) for _ in range(q)]

for e in x:
    si = bisect_left(s, e)
    ti = bisect_left(t, e)
    sl, sr = s[si-1], s[si]
    tl, tr = t[ti-1], t[ti]

    ans = INF
    ans = min(ans, e - min(sl, tl))
    ans = min(ans, max(sr, tr) - e)
    ans = min(ans, e - sl + tr - sl)
    ans = min(ans, e - tl + sr - tl)
    ans = min(ans, sr - e + sr - tl)
    ans = min(ans, tr - e + tr - sl)

    print(ans)
