import bisect as bi

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

s = [int(eval(input())) for i in range(a)]

t = [int(eval(input())) for i in range(b)]

for i in range(q):

    c = []

    d = []

    x = int(eval(input()))

    tmp = bi.bisect_left(s, x)

    if tmp != a : c.append(s[tmp])

    if tmp != 0 : c.append(s[tmp-1])

    tmp = bi.bisect_left(t, x)

    if tmp != b : d.append(t[tmp])

    if tmp != 0 : d.append(t[tmp-1])

    ans = 2**64

    for e in c:

        for f in d:

            g = abs(x-e)

            h = abs(x-f)

            if (x-e)*(x-f) > 0:

                ans = min(ans, max(g, h))

            else:

                if g > h : g,h = h,g

                ans = min(ans, 2*g+h)

    print(ans)
import bisect as bi

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

s = [int(eval(input())) for i in range(a)]

t = [int(eval(input())) for i in range(b)]

u = [int(eval(input())) for i in range(q)]



for x in u:

    c = []

    d = []

    tmp = bi.bisect_left(s, x)

    if tmp != a : c.append(s[tmp])

    if tmp != 0 : c.append(s[tmp-1])

    tmp = bi.bisect_left(t, x)

    if tmp != b : d.append(t[tmp])

    if tmp != 0 : d.append(t[tmp-1])

    ans = 2**64

    for e in c:

        for f in d:

            g = abs(x-e)

            h = abs(x-f)

            if (x-e)*(x-f) > 0:

                ans = min(ans, max(g, h))

            else:

                if g > h : g,h = h,g

                ans = min(ans, 2*g+h)

    print(ans)

import bisect as bi

a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for i in range(a)]
t = [int(eval(input())) for i in range(b)]
for i in range(q):
    c = []
    d = []
    x = int(eval(input()))
    tmp = bi.bisect_left(s, x)
    if tmp != a:
        c.append(s[tmp])
    if tmp != 0:
        c.append(s[tmp - 1])
    tmp = bi.bisect_left(t, x)
    if tmp != b:
        d.append(t[tmp])
    if tmp != 0:
        d.append(t[tmp - 1])
    ans = 2**64
    for e in c:
        for f in d:
            g = abs(x - e)
            h = abs(x - f)
            if (x - e) * (x - f) > 0:
                ans = min(ans, max(g, h))
            else:
                if g > h:
                    g, h = h, g
                ans = min(ans, 2 * g + h)
    print(ans)

import bisect as bi

a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for i in range(a)]
t = [int(eval(input())) for i in range(b)]
u = [int(eval(input())) for i in range(q)]
for x in u:
    c = []
    d = []
    tmp = bi.bisect_left(s, x)
    if tmp != a:
        c.append(s[tmp])
    if tmp != 0:
        c.append(s[tmp - 1])
    tmp = bi.bisect_left(t, x)
    if tmp != b:
        d.append(t[tmp])
    if tmp != 0:
        d.append(t[tmp - 1])
    ans = 2**64
    for e in c:
        for f in d:
            g = abs(x - e)
            h = abs(x - f)
            if (x - e) * (x - f) > 0:
                ans = min(ans, max(g, h))
            else:
                if g > h:
                    g, h = h, g
                ans = min(ans, 2 * g + h)
    print(ans)

-for i in range(q): +u = [int(eval(input())) for i in range(q)] +for x in u: -    x = int(eval(input()))