from bisect import bisect_left



inf = (10 ** 10) * 2 + 10



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



s = [-inf]

for _ in range(a):

    s.append(int(eval(input())))

s.append(inf)

s.sort()



t = [-inf]

for _ in range(b):

    t.append(int(eval(input())))

t.append(inf)

t.sort()



for _ in range(q):

    x = int(eval(input()))



    si = bisect_left(s, x) - 1

    ti = bisect_left(t, x) - 1



    ret = inf

    for sx in s[si:si + 2]:

        for tx in t[ti:ti + 2]:

            ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))

    print(ret)

def main():

    from bisect import bisect_left

    import sys



    input = sys.stdin.readline

    inf = (10 ** 10) * 2 + 10



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



    s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf]

    # s.sort()



    t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf]

    # t.sort()



    for _ in range(q):

        x = int(eval(input()))



        si = bisect_left(s, x) - 1

        ti = bisect_left(t, x) - 1



        ret = inf

        for sx in s[si:si + 2]:

            for tx in t[ti:ti + 2]:

                ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))

        print(ret)





if __name__ == '__main__':

    main()

from bisect import bisect_left

inf = (10**10) * 2 + 10
a, b, q = list(map(int, input().split()))
s = [-inf]
for _ in range(a):
    s.append(int(eval(input())))
s.append(inf)
s.sort()
t = [-inf]
for _ in range(b):
    t.append(int(eval(input())))
t.append(inf)
t.sort()
for _ in range(q):
    x = int(eval(input()))
    si = bisect_left(s, x) - 1
    ti = bisect_left(t, x) - 1
    ret = inf
    for sx in s[si : si + 2]:
        for tx in t[ti : ti + 2]:
            ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))
    print(ret)

def main():
    from bisect import bisect_left
    import sys

    input = sys.stdin.readline
    inf = (10**10) * 2 + 10
    a, b, q = list(map(int, input().split()))
    s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf]
    # s.sort()
    t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf]
    # t.sort()
    for _ in range(q):
        x = int(eval(input()))
        si = bisect_left(s, x) - 1
        ti = bisect_left(t, x) - 1
        ret = inf
        for sx in s[si : si + 2]:
            for tx in t[ti : ti + 2]:
                ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx))
        print(ret)


if __name__ == "__main__":
    main()

-from bisect import bisect_left +def main(): +    from bisect import bisect_left +    import sys -inf = (10**10) * 2 + 10 -a, b, q = list(map(int, input().split())) -s = [-inf] -for _ in range(a): -    s.append(int(eval(input()))) -s.append(inf) -s.sort() -t = [-inf] -for _ in range(b): -    t.append(int(eval(input()))) -t.append(inf) -t.sort() -for _ in range(q): -    x = int(eval(input())) -    si = bisect_left(s, x) - 1 -    ti = bisect_left(t, x) - 1 -    ret = inf -    for sx in s[si : si + 2]: -        for tx in t[ti : ti + 2]: -            ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) -    print(ret) +    input = sys.stdin.readline +    inf = (10**10) * 2 + 10 +    a, b, q = list(map(int, input().split())) +    s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] +    # s.sort() +    t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] +    # t.sort() +    for _ in range(q): +        x = int(eval(input())) +        si = bisect_left(s, x) - 1 +        ti = bisect_left(t, x) - 1 +        ret = inf +        for sx in s[si : si + 2]: +            for tx in t[ti : ti + 2]: +                ret = min(ret, min(abs(x - sx), abs(x - tx)) + abs(sx - tx)) +        print(ret) + + +if __name__ == "__main__": +    main()