import bisect



left_sentinel = -2 * (10 ** 10)

right_sentinel = 3 * (10 ** 10)



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

ss = [left_sentinel] + [int(eval(input())) for _ in range(A)] + [right_sentinel]

ts = [left_sentinel] + [int(eval(input())) for _ in range(B)] + [right_sentinel]



for _ in range(Q):

    x = int(eval(input()))

    s_index = bisect.bisect_left(ss, x)

    right_s = ss[s_index]

    left_s = ss[s_index - 1]

    t_index = bisect.bisect_left(ts, x)

    right_t = ts[t_index]

    left_t = ts[t_index - 1]

    ans = min(

        max(right_s, right_t) - x,

        right_s - left_t + min(right_s - x, x - left_t),

        right_t - left_s + min(right_t - x, x - left_s),

        x - min(left_s, left_t)

    )

    print(ans)

    
import sys

from bisect import *

input = sys.stdin.buffer.readline



INF = 10 ** 13



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

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

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

queries = [int(eval(input())) for _ in range(Q)]



for x in queries:

    s_index = bisect(shrines, x)

    t_index = bisect(temples, x)

    rs = shrines[s_index]

    rt = temples[t_index]

    ls = shrines[s_index - 1]

    lt = temples[t_index - 1]

    ans = INF

    ans = min(ans, max(rs, rt) - x)

    ans = min(ans, x - min(ls, lt))

    ans = min(ans, (rt - ls)*2 - max(rt-x, x-ls))    

    ans = min(ans, (rs - lt)*2 - max(rs-x, x-lt))

    print(ans)

    

     

import bisect

left_sentinel = -2 * (10**10)
right_sentinel = 3 * (10**10)
A, B, Q = list(map(int, input().split()))
ss = [left_sentinel] + [int(eval(input())) for _ in range(A)] + [right_sentinel]
ts = [left_sentinel] + [int(eval(input())) for _ in range(B)] + [right_sentinel]
for _ in range(Q):
    x = int(eval(input()))
    s_index = bisect.bisect_left(ss, x)
    right_s = ss[s_index]
    left_s = ss[s_index - 1]
    t_index = bisect.bisect_left(ts, x)
    right_t = ts[t_index]
    left_t = ts[t_index - 1]
    ans = min(
        max(right_s, right_t) - x,
        right_s - left_t + min(right_s - x, x - left_t),
        right_t - left_s + min(right_t - x, x - left_s),
        x - min(left_s, left_t),
    )
    print(ans)

import sys
from bisect import *

input = sys.stdin.buffer.readline
INF = 10**13
A, B, Q = list(map(int, input().split()))
shrines = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
temples = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
queries = [int(eval(input())) for _ in range(Q)]
for x in queries:
    s_index = bisect(shrines, x)
    t_index = bisect(temples, x)
    rs = shrines[s_index]
    rt = temples[t_index]
    ls = shrines[s_index - 1]
    lt = temples[t_index - 1]
    ans = INF
    ans = min(ans, max(rs, rt) - x)
    ans = min(ans, x - min(ls, lt))
    ans = min(ans, (rt - ls) * 2 - max(rt - x, x - ls))
    ans = min(ans, (rs - lt) * 2 - max(rs - x, x - lt))
    print(ans)

-import bisect +import sys +from bisect import * -left_sentinel = -2 * (10**10) -right_sentinel = 3 * (10**10) +input = sys.stdin.buffer.readline +INF = 10**13 -ss = [left_sentinel] + [int(eval(input())) for _ in range(A)] + [right_sentinel] -ts = [left_sentinel] + [int(eval(input())) for _ in range(B)] + [right_sentinel] -for _ in range(Q): -    x = int(eval(input())) -    s_index = bisect.bisect_left(ss, x) -    right_s = ss[s_index] -    left_s = ss[s_index - 1] -    t_index = bisect.bisect_left(ts, x) -    right_t = ts[t_index] -    left_t = ts[t_index - 1] -    ans = min( -        max(right_s, right_t) - x, -        right_s - left_t + min(right_s - x, x - left_t), -        right_t - left_s + min(right_t - x, x - left_s), -        x - min(left_s, left_t), -    ) +shrines = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] +temples = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] +queries = [int(eval(input())) for _ in range(Q)] +for x in queries: +    s_index = bisect(shrines, x) +    t_index = bisect(temples, x) +    rs = shrines[s_index] +    rt = temples[t_index] +    ls = shrines[s_index - 1] +    lt = temples[t_index - 1] +    ans = INF +    ans = min(ans, max(rs, rt) - x) +    ans = min(ans, x - min(ls, lt)) +    ans = min(ans, (rt - ls) * 2 - max(rt - x, x - ls)) +    ans = min(ans, (rs - lt) * 2 - max(rs - x, x - lt))