import bisect



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



s = [int(eval(input())) for i in range(a)]

t = [int(eval(input())) for i in range(b)]

x = [int(eval(input())) for i in range(q)]



ans = 10**100



for i in range(q):

    ans = 10**100

    s_idx = bisect.bisect_left(s,x[i])

    t_idx = bisect.bisect_left(t,x[i])

    s_idx -= 1

    t_idx -= 1

    #print(x[i],s_idx,t_idx)

    for j in range(2):

        for k in range(2):

            ans = min(ans,abs(x[i] - s[min(s_idx+j,a-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]),abs(x[i] - t[min(t_idx+k,b-1)]) + abs(s[min(s_idx+j,a-1)] - t[min(t_idx+k,b-1)]))

            

    print(ans)
import sys

import bisect

input = sys.stdin.readline



def f(x):

    if 0<=x and a-1>= x:

        return True

    return False

def g(x):

    if 0<=x and b-1>= x:

        return True

    return False



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

s = []

t = []

for i in range(a):

    S = int(eval(input()))

    s.append(S)

for i in range(b):

    T = int(eval(input()))

    t.append(T)

s.sort()

t.sort()

 

for i in range(q):

    x = int(eval(input()))

    p = bisect.bisect_left(s,x)

    m = bisect.bisect_left(t,x)

    

    res = []

    if f(p) and g(m):

        res.append(max(t[m],s[p])-x)

    if f(p) and g(m-1):

        res.append(min(s[p]-x,x-t[m-1])+s[p]-t[m-1])

    if f(p-1) and g(m):

        res.append(t[m]-s[p-1]+min(t[m]-x,x-s[p-1]))

    if f(p-1) and g(m-1):

        res.append(x-min(t[m-1],s[p-1]))

    print((min(res)))
import bisect

a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for i in range(a)]
t = [int(eval(input())) for i in range(b)]
x = [int(eval(input())) for i in range(q)]
ans = 10**100
for i in range(q):
    ans = 10**100
    s_idx = bisect.bisect_left(s, x[i])
    t_idx = bisect.bisect_left(t, x[i])
    s_idx -= 1
    t_idx -= 1
    # print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(
                ans,
                abs(x[i] - s[min(s_idx + j, a - 1)])
                + abs(s[min(s_idx + j, a - 1)] - t[min(t_idx + k, b - 1)]),
                abs(x[i] - t[min(t_idx + k, b - 1)])
                + abs(s[min(s_idx + j, a - 1)] - t[min(t_idx + k, b - 1)]),
            )
    print(ans)

import sys
import bisect

input = sys.stdin.readline


def f(x):
    if 0 <= x and a - 1 >= x:
        return True
    return False


def g(x):
    if 0 <= x and b - 1 >= x:
        return True
    return False


a, b, q = list(map(int, input().split()))
s = []
t = []
for i in range(a):
    S = int(eval(input()))
    s.append(S)
for i in range(b):
    T = int(eval(input()))
    t.append(T)
s.sort()
t.sort()
for i in range(q):
    x = int(eval(input()))
    p = bisect.bisect_left(s, x)
    m = bisect.bisect_left(t, x)
    res = []
    if f(p) and g(m):
        res.append(max(t[m], s[p]) - x)
    if f(p) and g(m - 1):
        res.append(min(s[p] - x, x - t[m - 1]) + s[p] - t[m - 1])
    if f(p - 1) and g(m):
        res.append(t[m] - s[p - 1] + min(t[m] - x, x - s[p - 1]))
    if f(p - 1) and g(m - 1):
        res.append(x - min(t[m - 1], s[p - 1]))
    print((min(res)))

+import sys +input = sys.stdin.readline + + +def f(x): +    if 0 <= x and a - 1 >= x: +        return True +    return False + + +def g(x): +    if 0 <= x and b - 1 >= x: +        return True +    return False + + -s = [int(eval(input())) for i in range(a)] -t = [int(eval(input())) for i in range(b)] -x = [int(eval(input())) for i in range(q)] -ans = 10**100 +s = [] +t = [] +for i in range(a): +    S = int(eval(input())) +    s.append(S) +for i in range(b): +    T = int(eval(input())) +    t.append(T) +s.sort() +t.sort() -    ans = 10**100 -    s_idx = bisect.bisect_left(s, x[i]) -    t_idx = bisect.bisect_left(t, x[i]) -    s_idx -= 1 -    t_idx -= 1 -    # print(x[i],s_idx,t_idx) -    for j in range(2): -        for k in range(2): -            ans = min( -                ans, -                abs(x[i] - s[min(s_idx + j, a - 1)]) -                + abs(s[min(s_idx + j, a - 1)] - t[min(t_idx + k, b - 1)]), -                abs(x[i] - t[min(t_idx + k, b - 1)]) -                + abs(s[min(s_idx + j, a - 1)] - t[min(t_idx + k, b - 1)]), -            ) -    print(ans) +    x = int(eval(input())) +    p = bisect.bisect_left(s, x) +    m = bisect.bisect_left(t, x) +    res = [] +    if f(p) and g(m): +        res.append(max(t[m], s[p]) - x) +    if f(p) and g(m - 1): +        res.append(min(s[p] - x, x - t[m - 1]) + s[p] - t[m - 1]) +    if f(p - 1) and g(m): +        res.append(t[m] - s[p - 1] + min(t[m] - x, x - s[p - 1])) +    if f(p - 1) and g(m - 1): +        res.append(x - min(t[m - 1], s[p - 1])) +    print((min(res)))