from bisect import bisect

import sys

input = sys.stdin.readline



A, B, Q = list(map(int, input().split()))

s = [int(eval(input())) for _ in range(A)]

s.sort()

t = [int(eval(input())) for _ in range(B)]

t.sort()

for _ in range(Q):

    x = int(eval(input()))

    i = bisect(s, x)

    sl = sr = 0

    if i == 0:

        sl = -float('inf')

        sr = s[i]

    elif i == A:

        sl = s[i-1]

        sr = float('inf')

    else:

        sl = s[i-1]

        sr = s[i]

    j = bisect(t, x)

    tl = tr = 0

    if j == 0:

        tl = -float('inf')

        tr = t[j]

    elif j == B:

        tl = t[j-1]

        tr = float('inf')

    else:

        tl = t[j-1]

        tr = t[j]

    ans = min(max(sr, tr)-x, x-min(sl, tl), x+sr-2*tl, x+tr-2*sl, 2*sr-x-tl, 2*tr-x-sl)

    print(ans)

from bisect import bisect

import sys

input = sys.stdin.readline



A, B, Q = list(map(int, input().split()))

INF = float('inf')

s = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]

t = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]

for _ in range(Q):

    x = int(eval(input()))

    i = bisect(s, x)

    j = bisect(t, x)

    ans = INF

    for a in [s[i-1], s[i]]:

        for b in [t[j-1], t[j]]:

            ans = min(ans, abs(a-x)+abs(b-a), abs(b-x)+abs(a-b))

    print(ans)

from bisect import bisect
import sys

input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(A)]
s.sort()
t = [int(eval(input())) for _ in range(B)]
t.sort()
for _ in range(Q):
    x = int(eval(input()))
    i = bisect(s, x)
    sl = sr = 0
    if i == 0:
        sl = -float("inf")
        sr = s[i]
    elif i == A:
        sl = s[i - 1]
        sr = float("inf")
    else:
        sl = s[i - 1]
        sr = s[i]
    j = bisect(t, x)
    tl = tr = 0
    if j == 0:
        tl = -float("inf")
        tr = t[j]
    elif j == B:
        tl = t[j - 1]
        tr = float("inf")
    else:
        tl = t[j - 1]
        tr = t[j]
    ans = min(
        max(sr, tr) - x,
        x - min(sl, tl),
        x + sr - 2 * tl,
        x + tr - 2 * sl,
        2 * sr - x - tl,
        2 * tr - x - sl,
    )
    print(ans)

from bisect import bisect
import sys

input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
INF = float("inf")
s = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
for _ in range(Q):
    x = int(eval(input()))
    i = bisect(s, x)
    j = bisect(t, x)
    ans = INF
    for a in [s[i - 1], s[i]]:
        for b in [t[j - 1], t[j]]:
            ans = min(ans, abs(a - x) + abs(b - a), abs(b - x) + abs(a - b))
    print(ans)

-s = [int(eval(input())) for _ in range(A)] -s.sort() -t = [int(eval(input())) for _ in range(B)] -t.sort() +INF = float("inf") +s = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] +t = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] -    sl = sr = 0 -    if i == 0: -        sl = -float("inf") -        sr = s[i] -    elif i == A: -        sl = s[i - 1] -        sr = float("inf") -    else: -        sl = s[i - 1] -        sr = s[i] -    tl = tr = 0 -    if j == 0: -        tl = -float("inf") -        tr = t[j] -    elif j == B: -        tl = t[j - 1] -        tr = float("inf") -    else: -        tl = t[j - 1] -        tr = t[j] -    ans = min( -        max(sr, tr) - x, -        x - min(sl, tl), -        x + sr - 2 * tl, -        x + tr - 2 * sl, -        2 * sr - x - tl, -        2 * tr - x - sl, -    ) +    ans = INF +    for a in [s[i - 1], s[i]]: +        for b in [t[j - 1], t[j]]: +            ans = min(ans, abs(a - x) + abs(b - a), abs(b - x) + abs(a - b))