# D

from bisect import bisect_right

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 q in range(Q):

    x = int(eval(input()))

    b,d = bisect_right(s, x), bisect_right(t, x)

    ans = INF

    for s_visit in [s[b-1], s[b]]:

        for t_visit in [t[d-1], t[d]]:

            dist1 = abs(s_visit - x) + abs(t_visit - s_visit)

            dist2 = abs(t_visit - x) + abs(s_visit - t_visit)

            ans = min(ans, dist1, dist2)

    print(ans)
# D

from bisect import bisect_right

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 q in range(Q):

    x = int(eval(input()))

    b,d = bisect_right(s, x), bisect_right(t, x)

    ans = INF

    for s_visit in [s[b-1], s[b]]:

        for t_visit in [t[d-1], t[d]]:

            dist1 = abs(s_visit - x) + abs(t_visit - s_visit)

            dist2 = abs(t_visit - x) + abs(s_visit - t_visit)

            ans = min(ans, dist1, dist2)

    print(ans)
# D
from bisect import bisect_right

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 q in range(Q):
    x = int(eval(input()))
    b, d = bisect_right(s, x), bisect_right(t, x)
    ans = INF
    for s_visit in [s[b - 1], s[b]]:
        for t_visit in [t[d - 1], t[d]]:
            dist1 = abs(s_visit - x) + abs(t_visit - s_visit)
            dist2 = abs(t_visit - x) + abs(s_visit - t_visit)
            ans = min(ans, dist1, dist2)
    print(ans)

# D
from bisect import bisect_right
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 q in range(Q):
    x = int(eval(input()))
    b, d = bisect_right(s, x), bisect_right(t, x)
    ans = INF
    for s_visit in [s[b - 1], s[b]]:
        for t_visit in [t[d - 1], t[d]]:
            dist1 = abs(s_visit - x) + abs(t_visit - s_visit)
            dist2 = abs(t_visit - x) + abs(s_visit - t_visit)
            ans = min(ans, dist1, dist2)
    print(ans)

+import sys +input = sys.stdin.readline