import bisect

a, b, q = map(int, input().split())
s = []
for i in range(a):
    s.append(int(input()))
s.sort()
t = []
for i in range(b):
    t.append(int(input()))
t.sort()

for i in range(q):
    x = int(input())
    temp_s = bisect.bisect(s, x)
    temp_t = bisect.bisect(t, x)
    temp = float("inf")
    if temp_s == 0:
        num = (s[0],)
    elif temp_s == a:
        num = (s[a - 1],)
    else:
        num = (s[temp_s - 1], s[temp_s])
    for j in num:
        temp2 = bisect.bisect(t, j)
        if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    if temp_t == 0:
        num = (t[0],)
    elif temp_t == b:
        num = (t[b - 1],)
    else:
        num = (t[temp_t - 1], t[temp_t])
    for j in num:
        temp2 = bisect.bisect(s, j)
        if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    print(temp) import bisect bisect a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q s = [] s [] for i in range(a):
    s.append(int(input())) i range(a) range a s.append(int(input())) s.append s append int(input()) int input() input s.sort() s.sort s sort t = [] t [] for i in range(b):
    t.append(int(input())) i range(b) range b t.append(int(input())) t.append t append int(input()) int input() input t.sort() t.sort t sort for i in range(q):
    x = int(input())
    temp_s = bisect.bisect(s, x)
    temp_t = bisect.bisect(t, x)
    temp = float("inf")
    if temp_s == 0:
        num = (s[0],)
    elif temp_s == a:
        num = (s[a - 1],)
    else:
        num = (s[temp_s - 1], s[temp_s])
    for j in num:
        temp2 = bisect.bisect(t, j)
        if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    if temp_t == 0:
        num = (t[0],)
    elif temp_t == b:
        num = (t[b - 1],)
    else:
        num = (t[temp_t - 1], t[temp_t])
    for j in num:
        temp2 = bisect.bisect(s, j)
        if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    print(temp) i range(q) range q x = int(input()) x int(input()) int input() input temp_s = bisect.bisect(s, x) temp_s bisect.bisect(s, x) bisect.bisect bisect bisect s x temp_t = bisect.bisect(t, x) temp_t bisect.bisect(t, x) bisect.bisect bisect bisect t x temp = float("inf") temp float("inf") float "inf" if temp_s == 0:
        num = (s[0],)
    elif temp_s == a:
        num = (s[a - 1],)
    else:
        num = (s[temp_s - 1], s[temp_s])
     temp_s == 0 temp_s 0 num = (s[0],) num s[0] s 0 elif temp_s == a:
        num = (s[a - 1],)
     temp_s == a temp_s a num = (s[a - 1],) num s[a - 1] s a - 1 a 1 num = (s[temp_s - 1], s[temp_s]) num (s[temp_s - 1], s[temp_s]) s[temp_s - 1] s temp_s - 1 temp_s 1 s[temp_s] s temp_s for j in num:
        temp2 = bisect.bisect(t, j)
        if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
     j num temp2 = bisect.bisect(t, j) temp2 bisect.bisect(t, j) bisect.bisect bisect bisect t j if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
         temp2 == 0 temp2 0 num2 = (t[0],) num2 t[0] t 0 elif temp2 == b:
            num2 = (t[b - 1],)
         temp2 == b temp2 b num2 = (t[b - 1],) num2 t[b - 1] t b - 1 b 1 num2 = (t[temp2 - 1], t[temp2]) num2 (t[temp2 - 1], t[temp2]) t[temp2 - 1] t temp2 - 1 temp2 1 t[temp2] t temp2 for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
     k num2 temp = min(temp, abs(x - j) + abs(j - k)) temp min(temp, abs(x - j) + abs(j - k)) min temp abs(x - j) + abs(j - k) abs(x - j) abs x - j x j abs(j - k) abs j - k j k if temp_t == 0:
        num = (t[0],)
    elif temp_t == b:
        num = (t[b - 1],)
    else:
        num = (t[temp_t - 1], t[temp_t])
     temp_t == 0 temp_t 0 num = (t[0],) num t[0] t 0 elif temp_t == b:
        num = (t[b - 1],)
     temp_t == b temp_t b num = (t[b - 1],) num t[b - 1] t b - 1 b 1 num = (t[temp_t - 1], t[temp_t]) num (t[temp_t - 1], t[temp_t]) t[temp_t - 1] t temp_t - 1 temp_t 1 t[temp_t] t temp_t for j in num:
        temp2 = bisect.bisect(s, j)
        if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
     j num temp2 = bisect.bisect(s, j) temp2 bisect.bisect(s, j) bisect.bisect bisect bisect s j if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
         temp2 == 0 temp2 0 num2 = (s[0],) num2 s[0] s 0 elif temp2 == a:
            num2 = (s[a - 1],)
         temp2 == a temp2 a num2 = (s[a - 1],) num2 s[a - 1] s a - 1 a 1 num2 = (s[temp2 - 1], s[temp2]) num2 (s[temp2 - 1], s[temp2]) s[temp2 - 1] s temp2 - 1 temp2 1 s[temp2] s temp2 for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
     k num2 temp = min(temp, abs(x - j) + abs(j - k)) temp min(temp, abs(x - j) + abs(j - k)) min temp abs(x - j) + abs(j - k) abs(x - j) abs x - j x j abs(j - k) abs j - k j k print(temp) print temp temp = float("inf") float("inf") temp temp = min(temp, abs(x - j) + abs(j - k)) min(temp, abs(x - j) + abs(j - k)) temp temp = min(temp, abs(x - j) + abs(j - k)) min(temp, abs(x - j) + abs(j - k)) temp num2 = (s[a - 1],) s[a - 1] num2 temp2 = bisect.bisect(s, j) bisect.bisect(s, j) temp2 temp_s = bisect.bisect(s, x) bisect.bisect(s, x) temp_s q = map(int, input().split()) map(int, input().split()) q num2 = (t[b - 1],) t[b - 1] num2 temp_t = bisect.bisect(t, x) bisect.bisect(t, x) temp_t a, b, q = map(int, input().split()) map(int, input().split()) a s = [] [] s t = [] [] t num = (s[a - 1],) s[a - 1] num num = (s[temp_s - 1], s[temp_s]) (s[temp_s - 1], s[temp_s]) num num2 = (s[temp2 - 1], s[temp2]) (s[temp2 - 1], s[temp2]) num2 num = (t[temp_t - 1], t[temp_t]) (t[temp_t - 1], t[temp_t]) num num2 = (t[temp2 - 1], t[temp2]) (t[temp2 - 1], t[temp2]) num2 num2 = (t[0],) t[0] num2 num = (t[0],) t[0] num temp2 = bisect.bisect(t, j) bisect.bisect(t, j) temp2 b, q = map(int, input().split()) map(int, input().split()) b num = (t[b - 1],) t[b - 1] num x = int(input()) int(input()) x num = (s[0],) s[0] num num2 = (s[0],) s[0] num2
import bisect

a, b, q = map(int, input().split())
s = []
for i in range(a):
    s.append(int(input()))
s.sort()
t = []
for i in range(b):
    t.append(int(input()))
t.sort()

for i in range(q):
    x = int(input())
    temp_s = bisect.bisect(s, x)
    temp_t = bisect.bisect(t, x)
    temp = float("inf")
    if temp_s == 0:
        num = (s[0],)
    elif temp_s == a:
        num = (s[a - 1],)
    else:
        num = (s[temp_s - 1], s[temp_s])
    for j in num:
        temp2 = bisect.bisect(t, j)
        if temp2 == 0:
            num2 = (t[0],)
        elif temp2 == b:
            num2 = (t[b - 1],)
        else:
            num2 = (t[temp2 - 1], t[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    if temp_t == 0:
        num = (t[0],)
    elif temp_t == b:
        num = (t[b - 1],)
    else:
        num = (t[temp_t - 1], t[temp_t])
    for j in num:
        temp2 = bisect.bisect(s, j)
        if temp2 == 0:
            num2 = (s[0],)
        elif temp2 == a:
            num2 = (s[a - 1],)
        else:
            num2 = (s[temp2 - 1], s[temp2])
        for k in num2:
            temp = min(temp, abs(x - j) + abs(j - k))
    print(temp)