from bisect import bisect_left

a,b,q,*stx = list(map(int,open(0).read().split()))

s = [-1e10] + stx[:a] + [2*1e10]

t = [-1e10] + stx[a:-q] + [2*1e10]

x = stx[-q:]

for i in x:

    pos_s = bisect_left(s,i)

    pos_t = bisect_left(t,i)

    sl = s[pos_s-1]; sr = s[pos_s]

    tl = t[pos_t-1]; tr = t[pos_t]

    ans = min( i-min(sl,tl), max(sr,tr)-i, (sr*2-i-tl), (tr*2-i-sl), (i+tr-sl*2), (i+sr-tl*2) )

    print(ans)
from bisect import bisect



def main():

    a,b,q,*stx = list(map(int,open(0).read().split()))

    s = [-1e10] + stx[:a] + [2*1e10]

    t = [-1e10] + stx[a:a+b] + [2*1e10]

    x = stx[a+b:a+b+q]

    for i in x:

        pos_s = bisect(s,i)

        pos_t = bisect(t,i)

        sl = s[pos_s-1]; sr = s[pos_s]

        tl = t[pos_t-1]; tr = t[pos_t]

        ans = min( i-min(sl,tl), max(sr,tr)-i, (sr-i) + (sr-tl), (tr-i) + (tr-sl), (i-sl) + (tr-sl), (i-tl) + (sr-tl) )

        print(ans)



if __name__ == '__main__':

    main()
from bisect import bisect_left

a, b, q, *stx = list(map(int, open(0).read().split()))
s = [-1e10] + stx[:a] + [2 * 1e10]
t = [-1e10] + stx[a:-q] + [2 * 1e10]
x = stx[-q:]
for i in x:
    pos_s = bisect_left(s, i)
    pos_t = bisect_left(t, i)
    sl = s[pos_s - 1]
    sr = s[pos_s]
    tl = t[pos_t - 1]
    tr = t[pos_t]
    ans = min(
        i - min(sl, tl),
        max(sr, tr) - i,
        (sr * 2 - i - tl),
        (tr * 2 - i - sl),
        (i + tr - sl * 2),
        (i + sr - tl * 2),
    )
    print(ans)

from bisect import bisect


def main():
    a, b, q, *stx = list(map(int, open(0).read().split()))
    s = [-1e10] + stx[:a] + [2 * 1e10]
    t = [-1e10] + stx[a : a + b] + [2 * 1e10]
    x = stx[a + b : a + b + q]
    for i in x:
        pos_s = bisect(s, i)
        pos_t = bisect(t, i)
        sl = s[pos_s - 1]
        sr = s[pos_s]
        tl = t[pos_t - 1]
        tr = t[pos_t]
        ans = min(
            i - min(sl, tl),
            max(sr, tr) - i,
            (sr - i) + (sr - tl),
            (tr - i) + (tr - sl),
            (i - sl) + (tr - sl),
            (i - tl) + (sr - tl),
        )
        print(ans)


if __name__ == "__main__":
    main()

-from bisect import bisect_left +from bisect import bisect -a, b, q, *stx = list(map(int, open(0).read().split())) -s = [-1e10] + stx[:a] + [2 * 1e10] -t = [-1e10] + stx[a:-q] + [2 * 1e10] -x = stx[-q:] -for i in x: -    pos_s = bisect_left(s, i) -    pos_t = bisect_left(t, i) -    sl = s[pos_s - 1] -    sr = s[pos_s] -    tl = t[pos_t - 1] -    tr = t[pos_t] -    ans = min( -        i - min(sl, tl), -        max(sr, tr) - i, -        (sr * 2 - i - tl), -        (tr * 2 - i - sl), -        (i + tr - sl * 2), -        (i + sr - tl * 2), -    ) -    print(ans) + +def main(): +    a, b, q, *stx = list(map(int, open(0).read().split())) +    s = [-1e10] + stx[:a] + [2 * 1e10] +    t = [-1e10] + stx[a : a + b] + [2 * 1e10] +    x = stx[a + b : a + b + q] +    for i in x: +        pos_s = bisect(s, i) +        pos_t = bisect(t, i) +        sl = s[pos_s - 1] +        sr = s[pos_s] +        tl = t[pos_t - 1] +        tr = t[pos_t] +        ans = min( +            i - min(sl, tl), +            max(sr, tr) - i, +            (sr - i) + (sr - tl), +            (tr - i) + (tr - sl), +            (i - sl) + (tr - sl), +            (i - tl) + (sr - tl), +        ) +        print(ans) + + +if __name__ == "__main__": +    main()