import numpy as np
import sys
input = sys.stdin.buffer.readline

a, b, q = map(int,input().split())
ab = [[-1, -10**11], [-1, 10**11]]
aa = [-10**11, 10**11]
bb = [-10**11, 10**11]
for i in range(a):
    x = int(input())
    ab.append([0, x])
    aa.append(x)
    
for i in range(b):
    x = int(input())
    ab.append([1, x])
    bb.append(x)
ab = sorted(ab, key=lambda x:(x[1], x[0]))
aa.sort()
bb.sort()

ab_arr = np.array(ab)
ab_arr = ab_arr.T[1]

a_arr = np.array(aa)
b_arr = np.array(bb)

for cq in range(q):
    ans = 10**12
    s = int(input())
    ci = np.searchsorted(ab_arr, s)
    for cj in [ci, ci-1]:
        d = abs(ab_arr[cj] - s)
        flg = ab[cj][0]
        if flg:
            na = np.searchsorted(a_arr, ab_arr[cj])
            d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj]))
            d += d2
        else:
            nb = np.searchsorted(b_arr, ab_arr[cj])
            d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj]))
            d += d2
        ans = min(ans, d)
    print(ans) import numpy as np numpy import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline a, b, q = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b q ab = [[-1, -10**11], [-1, 10**11]] ab [[-1, -10**11], [-1, 10**11]] [-1, -10**11] -1 -10**11 -10 11 [-1, 10**11] -1 10**11 10 11 aa = [-10**11, 10**11] aa [-10**11, 10**11] -10**11 -10 11 10**11 10 11 bb = [-10**11, 10**11] bb [-10**11, 10**11] -10**11 -10 11 10**11 10 11 for i in range(a):
    x = int(input())
    ab.append([0, x])
    aa.append(x)
     i range(a) range a x = int(input()) x int(input()) int input() input ab.append([0, x]) ab.append ab append [0, x] 0 x aa.append(x) aa.append aa append x for i in range(b):
    x = int(input())
    ab.append([1, x])
    bb.append(x) i range(b) range b x = int(input()) x int(input()) int input() input ab.append([1, x]) ab.append ab append [1, x] 1 x bb.append(x) bb.append bb append x ab = sorted(ab, key=lambda x:(x[1], x[0])) ab sorted(ab, key=lambda x:(x[1], x[0])) sorted ab key=lambda x:(x[1], x[0]) key lambda x:(x[1], x[0]) (x[1], x[0]) x[1] x 1 x[0] x 0 x aa.sort() aa.sort aa sort bb.sort() bb.sort bb sort ab_arr = np.array(ab) ab_arr np.array(ab) np.array np array ab ab_arr = ab_arr.T[1] ab_arr ab_arr.T[1] ab_arr.T ab_arr T 1 a_arr = np.array(aa) a_arr np.array(aa) np.array np array aa b_arr = np.array(bb) b_arr np.array(bb) np.array np array bb for cq in range(q):
    ans = 10**12
    s = int(input())
    ci = np.searchsorted(ab_arr, s)
    for cj in [ci, ci-1]:
        d = abs(ab_arr[cj] - s)
        flg = ab[cj][0]
        if flg:
            na = np.searchsorted(a_arr, ab_arr[cj])
            d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj]))
            d += d2
        else:
            nb = np.searchsorted(b_arr, ab_arr[cj])
            d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj]))
            d += d2
        ans = min(ans, d)
    print(ans) cq range(q) range q ans = 10**12 ans 10**12 10 12 s = int(input()) s int(input()) int input() input ci = np.searchsorted(ab_arr, s) ci np.searchsorted(ab_arr, s) np.searchsorted np searchsorted ab_arr s for cj in [ci, ci-1]:
        d = abs(ab_arr[cj] - s)
        flg = ab[cj][0]
        if flg:
            na = np.searchsorted(a_arr, ab_arr[cj])
            d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj]))
            d += d2
        else:
            nb = np.searchsorted(b_arr, ab_arr[cj])
            d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj]))
            d += d2
        ans = min(ans, d)
     cj [ci, ci-1] ci ci-1 ci 1 d = abs(ab_arr[cj] - s) d abs(ab_arr[cj] - s) abs ab_arr[cj] - s ab_arr[cj] ab_arr cj s flg = ab[cj][0] flg ab[cj][0] [cj] ab cj 0 if flg:
            na = np.searchsorted(a_arr, ab_arr[cj])
            d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj]))
            d += d2
        else:
            nb = np.searchsorted(b_arr, ab_arr[cj])
            d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj]))
            d += d2
         flg na = np.searchsorted(a_arr, ab_arr[cj]) na np.searchsorted(a_arr, ab_arr[cj]) np.searchsorted np searchsorted a_arr ab_arr[cj] ab_arr cj d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj])) d2 min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj])) min abs(a_arr[na] - ab_arr[cj]) abs a_arr[na] - ab_arr[cj] a_arr[na] a_arr na ab_arr[cj] ab_arr cj abs(a_arr[na-1] - ab_arr[cj]) abs a_arr[na-1] - ab_arr[cj] a_arr[na-1] a_arr na-1 na 1 ab_arr[cj] ab_arr cj d += d2 d d2 nb = np.searchsorted(b_arr, ab_arr[cj]) nb np.searchsorted(b_arr, ab_arr[cj]) np.searchsorted np searchsorted b_arr ab_arr[cj] ab_arr cj d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj])) d2 min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj])) min abs(b_arr[nb] - ab_arr[cj]) abs b_arr[nb] - ab_arr[cj] b_arr[nb] b_arr nb ab_arr[cj] ab_arr cj abs(b_arr[nb-1] - ab_arr[cj]) abs b_arr[nb-1] - ab_arr[cj] b_arr[nb-1] b_arr nb-1 nb 1 ab_arr[cj] ab_arr cj d += d2 d d2 ans = min(ans, d) ans min(ans, d) min ans d print(ans) print ans b_arr = np.array(bb) np.array(bb) b_arr q = map(int,input().split()) map(int,input().split()) q ab_arr = np.array(ab) np.array(ab) ab_arr nb = np.searchsorted(b_arr, ab_arr[cj]) np.searchsorted(b_arr, ab_arr[cj]) nb ab_arr = ab_arr.T[1] ab_arr.T[1] ab_arr d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj])) min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj])) d2 ci = np.searchsorted(ab_arr, s) np.searchsorted(ab_arr, s) ci d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj])) min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj])) d2 bb = [-10**11, 10**11] [-10**11, 10**11] bb d += d2 d2 d a_arr = np.array(aa) np.array(aa) a_arr x = int(input()) int(input()) x d += d2 d2 d input = sys.stdin.buffer.readline sys.stdin.buffer.readline input b, q = map(int,input().split()) map(int,input().split()) b d = abs(ab_arr[cj] - s) abs(ab_arr[cj] - s) d ab = sorted(ab, key=lambda x:(x[1], x[0])) sorted(ab, key=lambda x:(x[1], x[0])) ab flg = ab[cj][0] ab[cj][0] flg aa = [-10**11, 10**11] [-10**11, 10**11] aa x = int(input()) int(input()) x ans = min(ans, d) min(ans, d) ans ab = [[-1, -10**11], [-1, 10**11]] [[-1, -10**11], [-1, 10**11]] ab na = np.searchsorted(a_arr, ab_arr[cj]) np.searchsorted(a_arr, ab_arr[cj]) na ans = 10**12 10**12 ans s = int(input()) int(input()) s a, b, q = map(int,input().split()) map(int,input().split()) a
import numpy as np
import sys
input = sys.stdin.buffer.readline

a, b, q = map(int,input().split())
ab = [[-1, -10**11], [-1, 10**11]]
aa = [-10**11, 10**11]
bb = [-10**11, 10**11]
for i in range(a):
    x = int(input())
    ab.append([0, x])
    aa.append(x)
    
for i in range(b):
    x = int(input())
    ab.append([1, x])
    bb.append(x)
ab = sorted(ab, key=lambda x:(x[1], x[0]))
aa.sort()
bb.sort()

ab_arr = np.array(ab)
ab_arr = ab_arr.T[1]

a_arr = np.array(aa)
b_arr = np.array(bb)

for cq in range(q):
    ans = 10**12
    s = int(input())
    ci = np.searchsorted(ab_arr, s)
    for cj in [ci, ci-1]:
        d = abs(ab_arr[cj] - s)
        flg = ab[cj][0]
        if flg:
            na = np.searchsorted(a_arr, ab_arr[cj])
            d2 = min(abs(a_arr[na] - ab_arr[cj]), abs(a_arr[na-1] - ab_arr[cj]))
            d += d2
        else:
            nb = np.searchsorted(b_arr, ab_arr[cj])
            d2 = min(abs(b_arr[nb] - ab_arr[cj]), abs(b_arr[nb-1] - ab_arr[cj]))
            d += d2
        ans = min(ans, d)
    print(ans)