import bisect
a, b, q = map(int, input().split())
ss = [int(input()) for _ in range(a)]
ts = [int(input()) for _ in range(b)]
xs = [int(input()) for _ in range(q)]
ss = [-float('inf')] + ss + [float('inf')]
ts = [-float('inf')] + ts + [float('inf')]
for x in xs:
    s_r = bisect.bisect_left(ss, x)
    t_r = bisect.bisect_left(ts, x)
    s_l = s_r - 1
    t_l = t_r - 1
    res = float('inf')
    if ss[s_l] > ts[t_l]:
        res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x))
    elif ss[s_l] < ts[t_l]:
        res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x))
    else:
        res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x))
    if ss[s_r] > ts[t_r]:
        res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l]))
    elif ss[s_r] < ts[t_r]:
        res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l]))
    else:
        res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l]))
    print(res) import bisect bisect a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input ss = [int(input()) for _ in range(a)] ss [int(input()) for _ in range(a)] int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input ts = [int(input()) for _ in range(b)] ts [int(input()) for _ in range(b)] int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input xs = [int(input()) for _ in range(q)] xs [int(input()) for _ in range(q)] ss = [-float('inf')] + ss + [float('inf')] ss [-float('inf')] + ss + [float('inf')] [-float('inf')] + ss [-float('inf')] -float('inf') float('inf') float 'inf' ss [float('inf')] float('inf') float 'inf' ts = [-float('inf')] + ts + [float('inf')] ts [-float('inf')] + ts + [float('inf')] [-float('inf')] + ts [-float('inf')] -float('inf') float('inf') float 'inf' ts [float('inf')] float('inf') float 'inf' for x in xs:
    s_r = bisect.bisect_left(ss, x)
    t_r = bisect.bisect_left(ts, x)
    s_l = s_r - 1
    t_l = t_r - 1
    res = float('inf')
    if ss[s_l] > ts[t_l]:
        res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x))
    elif ss[s_l] < ts[t_l]:
        res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x))
    else:
        res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x))
    if ss[s_r] > ts[t_r]:
        res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l]))
    elif ss[s_r] < ts[t_r]:
        res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l]))
    else:
        res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l]))
    print(res) x xs s_r = bisect.bisect_left(ss, x) s_r bisect.bisect_left(ss, x) bisect.bisect_left bisect bisect_left ss x t_r = bisect.bisect_left(ts, x) t_r bisect.bisect_left(ts, x) bisect.bisect_left bisect bisect_left ts x s_l = s_r - 1 s_l s_r - 1 s_r 1 t_l = t_r - 1 t_l t_r - 1 t_r 1 res = float('inf') res float('inf') float 'inf' if ss[s_l] > ts[t_l]:
        res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x))
    elif ss[s_l] < ts[t_l]:
        res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x))
    else:
        res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x))
     ss[s_l] > ts[t_l] ss[s_l] ss s_l ts[t_l] ts t_l res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x)) res min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x)) min res x - ts[t_l] x ts[t_l] ts t_l (x - ss[s_l])*2 + (ts[t_r] - x) (x - ss[s_l])*2 x - ss[s_l] x ss[s_l] ss s_l 2 ts[t_r] - x ts[t_r] ts t_r x elif ss[s_l] < ts[t_l]:
        res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x))
     ss[s_l] < ts[t_l] ss[s_l] ss s_l ts[t_l] ts t_l res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x)) res min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x)) min res x - ss[s_l] x ss[s_l] ss s_l (x - ts[t_l])*2 + (ss[s_r] - x) (x - ts[t_l])*2 x - ts[t_l] x ts[t_l] ts t_l 2 ss[s_r] - x ss[s_r] ss s_r x res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x)) res min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x)) min res (x - ss[s_l])*2 + (ss[s_r] - x) (x - ss[s_l])*2 x - ss[s_l] x ss[s_l] ss s_l 2 ss[s_r] - x ss[s_r] ss s_r x x - ss[s_l]*2 + (ts[t_r] - x) x - ss[s_l]*2 x ss[s_l]*2 ss[s_l] ss s_l 2 ts[t_r] - x ts[t_r] ts t_r x if ss[s_r] > ts[t_r]:
        res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l]))
    elif ss[s_r] < ts[t_r]:
        res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l]))
    else:
        res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l]))
     ss[s_r] > ts[t_r] ss[s_r] ss s_r ts[t_r] ts t_r res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l])) res min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l])) min res ss[s_r] - x ss[s_r] ss s_r x (ts[t_r] - x)*2 + (x - ss[s_l]) (ts[t_r] - x)*2 ts[t_r] - x ts[t_r] ts t_r x 2 x - ss[s_l] x ss[s_l] ss s_l elif ss[s_r] < ts[t_r]:
        res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l]))
     ss[s_r] < ts[t_r] ss[s_r] ss s_r ts[t_r] ts t_r res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l])) res min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l])) min res ts[t_r] - x ts[t_r] ts t_r x (ss[s_r] - x)*2 + (x - ts[t_l]) (ss[s_r] - x)*2 ss[s_r] - x ss[s_r] ss s_r x 2 x - ts[t_l] x ts[t_l] ts t_l res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l])) res min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l])) min res (ss[s_r] - x)*2 + (x - ss[s_l]) (ss[s_r] - x)*2 ss[s_r] - x ss[s_r] ss s_r x 2 x - ss[s_l] x ss[s_l] ss s_l (ss[s_r] - x)*2 + (x - ts[t_l]) (ss[s_r] - x)*2 ss[s_r] - x ss[s_r] ss s_r x 2 x - ts[t_l] x ts[t_l] ts t_l print(res) print res xs = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] xs ss = [int(input()) for _ in range(a)] [int(input()) for _ in range(a)] ss ss = [-float('inf')] + ss + [float('inf')] [-float('inf')] + ss + [float('inf')] ss b, q = map(int, input().split()) map(int, input().split()) b res = float('inf') float('inf') res a, b, q = map(int, input().split()) map(int, input().split()) a res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x)) min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x)) res res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x)) min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x)) res q = map(int, input().split()) map(int, input().split()) q t_l = t_r - 1 t_r - 1 t_l s_l = s_r - 1 s_r - 1 s_l res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l])) min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l])) res s_r = bisect.bisect_left(ss, x) bisect.bisect_left(ss, x) s_r ts = [-float('inf')] + ts + [float('inf')] [-float('inf')] + ts + [float('inf')] ts ts = [int(input()) for _ in range(b)] [int(input()) for _ in range(b)] ts t_r = bisect.bisect_left(ts, x) bisect.bisect_left(ts, x) t_r res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x)) min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x)) res res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l])) min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l])) res res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l])) min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l])) res
import bisect
a, b, q = map(int, input().split())
ss = [int(input()) for _ in range(a)]
ts = [int(input()) for _ in range(b)]
xs = [int(input()) for _ in range(q)]
ss = [-float('inf')] + ss + [float('inf')]
ts = [-float('inf')] + ts + [float('inf')]
for x in xs:
    s_r = bisect.bisect_left(ss, x)
    t_r = bisect.bisect_left(ts, x)
    s_l = s_r - 1
    t_l = t_r - 1
    res = float('inf')
    if ss[s_l] > ts[t_l]:
        res = min(res, x - ts[t_l], (x - ss[s_l])*2 + (ts[t_r] - x))
    elif ss[s_l] < ts[t_l]:
        res = min(res, x - ss[s_l], (x - ts[t_l])*2 + (ss[s_r] - x))
    else:
        res = min(res, (x - ss[s_l])*2 + (ss[s_r] - x), x - ss[s_l]*2 + (ts[t_r] - x))
    if ss[s_r] > ts[t_r]:
        res = min(res, ss[s_r] - x, (ts[t_r] - x)*2 + (x - ss[s_l]))
    elif ss[s_r] < ts[t_r]:
        res = min(res, ts[t_r] - x, (ss[s_r] - x)*2 + (x - ts[t_l]))
    else:
        res = min(res, (ss[s_r] - x)*2 + (x - ss[s_l]), (ss[s_r] - x)*2 + (x - ts[t_l]))
    print(res)