import bisect

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

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

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

for i in range(q):

    x = int(eval(input()))

    idx_s = bisect.bisect_left(s, x)

    idx_t = bisect.bisect_left(t, x)



    indices_s = []

    indices_t = []



    if idx_s == 0:

        indices_s.append(0)

    elif idx_s == a:

        indices_s.append(a-1)

    else:

        indices_s.append(idx_s)

        indices_s.append(idx_s-1)



    if idx_t == 0:

        indices_t.append(0)

    elif idx_t == b:

        indices_t.append(b-1)

    else:

        indices_t.append(idx_t)

        indices_t.append(idx_t-1)



    ans = []

    for i in indices_s:

        for j in indices_t:

            l, r = min(s[i], t[j]), max(s[i], t[j])

            if x < l:

                ans.append(r-x)

            elif l <= x and x < r:

                ans.append(min(r-l+(x-l), r-l+(r-x)))

            else:

                ans.append(x-l)

    print((min(ans)))



import sys

import bisect

input = sys.stdin.readline

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

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

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

for i in range(q):

    x = int(eval(input()))

    idx_s = bisect.bisect_left(s, x)

    idx_t = bisect.bisect_left(t, x)



    indices_s = []

    indices_t = []



    if idx_s == 0:

        indices_s.append(0)

    elif idx_s == a:

        indices_s.append(a-1)

    else:

        indices_s.append(idx_s)

        indices_s.append(idx_s-1)



    if idx_t == 0:

        indices_t.append(0)

    elif idx_t == b:

        indices_t.append(b-1)

    else:

        indices_t.append(idx_t)

        indices_t.append(idx_t-1)



    ans = []

    for i in indices_s:

        for j in indices_t:

            l, r = min(s[i], t[j]), max(s[i], t[j])

            if x < l:

                ans.append(r-x)

            elif l <= x and x < r:

                ans.append(min(r-l+(x-l), r-l+(r-x)))

            else:

                ans.append(x-l)

    print((min(ans)))



import bisect

a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
for i in range(q):
    x = int(eval(input()))
    idx_s = bisect.bisect_left(s, x)
    idx_t = bisect.bisect_left(t, x)
    indices_s = []
    indices_t = []
    if idx_s == 0:
        indices_s.append(0)
    elif idx_s == a:
        indices_s.append(a - 1)
    else:
        indices_s.append(idx_s)
        indices_s.append(idx_s - 1)
    if idx_t == 0:
        indices_t.append(0)
    elif idx_t == b:
        indices_t.append(b - 1)
    else:
        indices_t.append(idx_t)
        indices_t.append(idx_t - 1)
    ans = []
    for i in indices_s:
        for j in indices_t:
            l, r = min(s[i], t[j]), max(s[i], t[j])
            if x < l:
                ans.append(r - x)
            elif l <= x and x < r:
                ans.append(min(r - l + (x - l), r - l + (r - x)))
            else:
                ans.append(x - l)
    print((min(ans)))

import sys
import bisect

input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
s = [int(eval(input())) for _ in range(a)]
t = [int(eval(input())) for _ in range(b)]
for i in range(q):
    x = int(eval(input()))
    idx_s = bisect.bisect_left(s, x)
    idx_t = bisect.bisect_left(t, x)
    indices_s = []
    indices_t = []
    if idx_s == 0:
        indices_s.append(0)
    elif idx_s == a:
        indices_s.append(a - 1)
    else:
        indices_s.append(idx_s)
        indices_s.append(idx_s - 1)
    if idx_t == 0:
        indices_t.append(0)
    elif idx_t == b:
        indices_t.append(b - 1)
    else:
        indices_t.append(idx_t)
        indices_t.append(idx_t - 1)
    ans = []
    for i in indices_s:
        for j in indices_t:
            l, r = min(s[i], t[j]), max(s[i], t[j])
            if x < l:
                ans.append(r - x)
            elif l <= x and x < r:
                ans.append(min(r - l + (x - l), r - l + (r - x)))
            else:
                ans.append(x - l)
    print((min(ans)))

+import sys +input = sys.stdin.readline