import bisect

INF=10**11

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

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

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

for _ in range(q):

  x=int(eval(input()))

  i=bisect.bisect_left(a,x)

  j=bisect.bisect_left(b,x)

  ans=min(max(a[i],b[j])-x,x-min(a[i-1],b[j-1]),a[i]-b[j-1]+min(a[i]-x,x-b[j-1]),b[j]-a[i-1]+min(b[j]-x,x-a[i-1]))

  print(ans)
from bisect import*

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

s=[-10**18]+[int(eval(input())) for _ in range(a)]+[10**18]

t=[-10**18]+[int(eval(input())) for _ in range(b)]+[10**18]

for _ in range(q):

  i=int(eval(input()))

  si=bisect_left(s,i)

  ti=bisect_left(t,i)

  print((min(max(s[si],t[ti])-i,i-min(t[ti-1],s[si-1]),

            2*t[ti]-s[si-1]-i,2*s[si]-t[ti-1]-i,

            i+t[ti]-2*s[si-1],i+s[si]-2*t[ti-1])))
import bisect

INF = 10**11
A, B, q = list(map(int, input().split()))
a = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
b = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
for _ in range(q):
    x = int(eval(input()))
    i = bisect.bisect_left(a, x)
    j = bisect.bisect_left(b, x)
    ans = min(
        max(a[i], b[j]) - x,
        x - min(a[i - 1], b[j - 1]),
        a[i] - b[j - 1] + min(a[i] - x, x - b[j - 1]),
        b[j] - a[i - 1] + min(b[j] - x, x - a[i - 1]),
    )
    print(ans)

from bisect import *

a, b, q = list(map(int, input().split()))
s = [-(10**18)] + [int(eval(input())) for _ in range(a)] + [10**18]
t = [-(10**18)] + [int(eval(input())) for _ in range(b)] + [10**18]
for _ in range(q):
    i = int(eval(input()))
    si = bisect_left(s, i)
    ti = bisect_left(t, i)
    print(
        (
            min(
                max(s[si], t[ti]) - i,
                i - min(t[ti - 1], s[si - 1]),
                2 * t[ti] - s[si - 1] - i,
                2 * s[si] - t[ti - 1] - i,
                i + t[ti] - 2 * s[si - 1],
                i + s[si] - 2 * t[ti - 1],
            )
        )
    )

-import bisect +from bisect import * -INF = 10**11 -A, B, q = list(map(int, input().split())) -a = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] -b = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] +a, b, q = list(map(int, input().split())) +s = [-(10**18)] + [int(eval(input())) for _ in range(a)] + [10**18] +t = [-(10**18)] + [int(eval(input())) for _ in range(b)] + [10**18] -    x = int(eval(input())) -    i = bisect.bisect_left(a, x) -    j = bisect.bisect_left(b, x) -    ans = min( -        max(a[i], b[j]) - x, -        x - min(a[i - 1], b[j - 1]), -        a[i] - b[j - 1] + min(a[i] - x, x - b[j - 1]), -        b[j] - a[i - 1] + min(b[j] - x, x - a[i - 1]), +    i = int(eval(input())) +    si = bisect_left(s, i) +    ti = bisect_left(t, i) +    print( +        ( +            min( +                max(s[si], t[ti]) - i, +                i - min(t[ti - 1], s[si - 1]), +                2 * t[ti] - s[si - 1] - i, +                2 * s[si] - t[ti - 1] - i, +                i + t[ti] - 2 * s[si - 1], +                i + s[si] - 2 * t[ti - 1], +            ) +        ) -    print(ans)