import bisect,sys

input = sys.stdin.readline

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

INF = float('inf')

S = [-INF]+[int(eval(input())) for i in range(a)]+[INF]

T = [-INF]+[int(eval(input())) for i in range(b)]+[INF]



def f(S,T):

    res = INF

    s = bisect.bisect_left(S,x)

    for i in range(2):

    	for j in range(2):

            t = bisect.bisect_left(T,S[s-i])

            ans= abs(x-S[s-i])+abs(S[s-i]-T[t-j])

            if ans < res:

                res = ans

    return res



for i in range(q):

    x = int(eval(input()))

    print((min(f(S,T),f(T,S))))

from bisect import bisect_left

import sys

input = sys.stdin.readline

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

inf = float('inf')

S = [-inf]+[int(eval(input())) for i in range(a)]+[inf]

T = [-inf]+[int(eval(input())) for i in range(b)]+[inf]



def f(S,T):

    res = 10**30 

    s = bisect_left(S,x)



    ans = 0

    t = bisect_left(T,S[s-1])

    ans += abs(x-S[s-1])+min(abs(S[s-1]-T[t-1]),abs(S[s-1]-T[t]))

    if ans <= res:

        res = ans

    

    ans = 0

    t = bisect_left(T,S[s])

    ans += abs(x-S[s])+min(abs(S[s]-T[t-1]),abs(S[s]-T[t]))

    if ans <= res:

        res = ans



    return res





for i in range(q):

    x = int(eval(input()))

    print((min(f(S,T),f(T,S))))

import bisect, sys

input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
INF = float("inf")
S = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
T = [-INF] + [int(eval(input())) for i in range(b)] + [INF]


def f(S, T):
    res = INF
    s = bisect.bisect_left(S, x)
    for i in range(2):
        for j in range(2):
            t = bisect.bisect_left(T, S[s - i])
            ans = abs(x - S[s - i]) + abs(S[s - i] - T[t - j])
            if ans < res:
                res = ans
    return res


for i in range(q):
    x = int(eval(input()))
    print((min(f(S, T), f(T, S))))

from bisect import bisect_left
import sys

input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
inf = float("inf")
S = [-inf] + [int(eval(input())) for i in range(a)] + [inf]
T = [-inf] + [int(eval(input())) for i in range(b)] + [inf]


def f(S, T):
    res = 10**30
    s = bisect_left(S, x)
    ans = 0
    t = bisect_left(T, S[s - 1])
    ans += abs(x - S[s - 1]) + min(abs(S[s - 1] - T[t - 1]), abs(S[s - 1] - T[t]))
    if ans <= res:
        res = ans
    ans = 0
    t = bisect_left(T, S[s])
    ans += abs(x - S[s]) + min(abs(S[s] - T[t - 1]), abs(S[s] - T[t]))
    if ans <= res:
        res = ans
    return res


for i in range(q):
    x = int(eval(input()))
    print((min(f(S, T), f(T, S))))

-import bisect, sys +from bisect import bisect_left +import sys -INF = float("inf") -S = [-INF] + [int(eval(input())) for i in range(a)] + [INF] -T = [-INF] + [int(eval(input())) for i in range(b)] + [INF] +inf = float("inf") +S = [-inf] + [int(eval(input())) for i in range(a)] + [inf] +T = [-inf] + [int(eval(input())) for i in range(b)] + [inf] -    res = INF -    s = bisect.bisect_left(S, x) -    for i in range(2): -        for j in range(2): -            t = bisect.bisect_left(T, S[s - i]) -            ans = abs(x - S[s - i]) + abs(S[s - i] - T[t - j]) -            if ans < res: -                res = ans +    res = 10**30 +    s = bisect_left(S, x) +    ans = 0 +    t = bisect_left(T, S[s - 1]) +    ans += abs(x - S[s - 1]) + min(abs(S[s - 1] - T[t - 1]), abs(S[s - 1] - T[t])) +    if ans <= res: +        res = ans +    ans = 0 +    t = bisect_left(T, S[s]) +    ans += abs(x - S[s]) + min(abs(S[s] - T[t - 1]), abs(S[s] - T[t])) +    if ans <= res: +        res = ans