import bisect

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

sa = [None] * a
for i in range(a):
    sa[i] = (int(input()))

tb = [None] * b
for i in range(b):
    tb[i] = (int(input()))

xq = [None] * q
for i in range(q):
    xq[i] = (int(input()))

sa = [-inf] + sa + [inf]
tb = [-inf] + tb + [inf]

for x in xq:
    result = float('inf')

    l = bisect.bisect_left(sa, x)
    m = bisect.bisect_left(tb, x)

    for v in [sa[l - 1], sa[l]]:
        for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

    print(result)
 import bisect bisect a, b, q = list(map(int, input().split(' '))) a list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' b q inf = float('inf') inf float('inf') float 'inf' sa = [None] * a sa [None] * a [None] None a for i in range(a):
    sa[i] = (int(input())) i range(a) range a sa[i] = (int(input())) sa[i] sa i int(input()) int input() input tb = [None] * b tb [None] * b [None] None b for i in range(b):
    tb[i] = (int(input())) i range(b) range b tb[i] = (int(input())) tb[i] tb i int(input()) int input() input xq = [None] * q xq [None] * q [None] None q for i in range(q):
    xq[i] = (int(input())) i range(q) range q xq[i] = (int(input())) xq[i] xq i int(input()) int input() input sa = [-inf] + sa + [inf] sa [-inf] + sa + [inf] [-inf] + sa [-inf] -inf inf sa [inf] inf tb = [-inf] + tb + [inf] tb [-inf] + tb + [inf] [-inf] + tb [-inf] -inf inf tb [inf] inf for x in xq:
    result = float('inf')

    l = bisect.bisect_left(sa, x)
    m = bisect.bisect_left(tb, x)

    for v in [sa[l - 1], sa[l]]:
        for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

    print(result) x xq result = float('inf') result float('inf') float 'inf' l = bisect.bisect_left(sa, x) l bisect.bisect_left(sa, x) bisect.bisect_left bisect bisect_left sa x m = bisect.bisect_left(tb, x) m bisect.bisect_left(tb, x) bisect.bisect_left bisect bisect_left tb x for v in [sa[l - 1], sa[l]]:
        for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

     v [sa[l - 1], sa[l]] sa[l - 1] sa l - 1 l 1 sa[l] sa l for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

     w [tb[m - 1], tb[m]] tb[m - 1] tb m - 1 m 1 tb[m] tb m o = abs(x - v) + abs(v - w) o abs(x - v) + abs(v - w) abs(x - v) abs x - v x v abs(v - w) abs v - w v w p = abs(x - w) + abs(w - v) p abs(x - w) + abs(w - v) abs(x - w) abs x - w x w abs(w - v) abs w - v w v result = min(result, o, p) result min(result, o, p) min result o p print(result) print result tb = [-inf] + tb + [inf] [-inf] + tb + [inf] tb result = float('inf') float('inf') result inf = float('inf') float('inf') inf o = abs(x - v) + abs(v - w) abs(x - v) + abs(v - w) o m = bisect.bisect_left(tb, x) bisect.bisect_left(tb, x) m sa = [None] * a [None] * a sa p = abs(x - w) + abs(w - v) abs(x - w) + abs(w - v) p b, q = list(map(int, input().split(' '))) list(map(int, input().split(' '))) b result = min(result, o, p) min(result, o, p) result tb = [None] * b [None] * b tb a, b, q = list(map(int, input().split(' '))) list(map(int, input().split(' '))) a xq = [None] * q [None] * q xq q = list(map(int, input().split(' '))) list(map(int, input().split(' '))) q l = bisect.bisect_left(sa, x) bisect.bisect_left(sa, x) l sa = [-inf] + sa + [inf] [-inf] + sa + [inf] sa
import bisect

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

sa = [None] * a
for i in range(a):
    sa[i] = (int(input()))

tb = [None] * b
for i in range(b):
    tb[i] = (int(input()))

xq = [None] * q
for i in range(q):
    xq[i] = (int(input()))

sa = [-inf] + sa + [inf]
tb = [-inf] + tb + [inf]

for x in xq:
    result = float('inf')

    l = bisect.bisect_left(sa, x)
    m = bisect.bisect_left(tb, x)

    for v in [sa[l - 1], sa[l]]:
        for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

    print(result)

