import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, Q = LI()
    s = [I() for _ in range(A)]
    t = [I() for _ in range(B)]

    # xから一番近い神社に行く→その神社から一番近い寺に行く、またはその逆の2パターン

    # 各神社に対する一番近い寺の距離を求めておく
    len_of_nearest_t = [INF] * A
    for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
    len_of_nearest_s = [INF] * B
    for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

    for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s))

if __name__ == '__main__':
    resolve() import bisect, collections, copy, heapq, itertools, math, string, sys bisect collections copy heapq itertools math string sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = float('inf') INF float('inf') float 'inf' def I(): return int(input()) I def F(): return float(input()) F def SS(): return input() SS int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI(): return [int(x) for x in input().split()] LI int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 def LI_(): return [int(x)-1 for x in input().split()] LI_ float(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() float(x) float x def LF(): return [float(x) for x in input().split()] LF def LSS(): return input().split() LSS def resolve():
    A, B, Q = LI()
    s = [I() for _ in range(A)]
    t = [I() for _ in range(B)]

    # xから一番近い神社に行く→その神社から一番近い寺に行く、またはその逆の2パターン

    # 各神社に対する一番近い寺の距離を求めておく
    len_of_nearest_t = [INF] * A
    for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
    len_of_nearest_s = [INF] * B
    for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

    for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s)) resolve A, B, Q = LI() A LI() LI B Q I() for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) I() I s = [I() for _ in range(A)] s [I() for _ in range(A)] I() for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) I() I t = [I() for _ in range(B)] t [I() for _ in range(B)] len_of_nearest_t = [INF] * A len_of_nearest_t [INF] * A [INF] INF A for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
     i range(A) range A idx = bisect.bisect_left(t, s[i]) idx bisect.bisect_left(t, s[i]) bisect.bisect_left bisect bisect_left t s[i] s i len_r = t[idx] - s[i] if 0 <= idx < B else INF len_r t[idx] - s[i] if 0 <= idx < B else INF 0 <= idx < B 0 <= idx 0 idx B t[idx] - s[i] t[idx] t idx s[i] s i INF len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF len_l s[i] - t[idx-1] if 0 <= idx - 1 < B else INF 0 <= idx - 1 < B 0 <= idx - 1 0 idx - 1 idx 1 B s[i] - t[idx-1] s[i] s i t[idx-1] t idx-1 idx 1 INF len_of_nearest_t[i] = min(len_l, len_r) len_of_nearest_t[i] len_of_nearest_t i min(len_l, len_r) min len_l len_r len_of_nearest_s = [INF] * B len_of_nearest_s [INF] * B [INF] INF B for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

     i range(B) range B idx = bisect.bisect_left(s, t[i]) idx bisect.bisect_left(s, t[i]) bisect.bisect_left bisect bisect_left s t[i] t i len_r = s[idx] - t[i] if 0 <= idx < A else INF len_r s[idx] - t[i] if 0 <= idx < A else INF 0 <= idx < A 0 <= idx 0 idx A s[idx] - t[i] s[idx] s idx t[i] t i INF len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF len_l t[i] - s[idx-1] if 0 <= idx - 1 < A else INF 0 <= idx - 1 < A 0 <= idx - 1 0 idx - 1 idx 1 A t[i] - s[idx-1] t[i] t i s[idx-1] s idx-1 idx 1 INF len_of_nearest_s[i] = min(len_l, len_r) len_of_nearest_s[i] len_of_nearest_s i min(len_l, len_r) min len_l len_r for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s)) _ range(Q) range Q x = I() x I() I idx = bisect.bisect_left(s, x) idx bisect.bisect_left(s, x) bisect.bisect_left bisect bisect_left s x len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF len_r s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF 0 <= idx < A 0 <= idx 0 idx A s[idx] - x + len_of_nearest_t[idx] s[idx] - x s[idx] s idx x len_of_nearest_t[idx] len_of_nearest_t idx INF len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF len_l x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF 0 <= idx - 1 < A 0 <= idx - 1 0 idx - 1 idx 1 A x - s[idx-1] + len_of_nearest_t[idx-1] x - s[idx-1] x s[idx-1] s idx-1 idx 1 len_of_nearest_t[idx-1] len_of_nearest_t idx-1 idx 1 INF len_x_s_t = min(len_r, len_l) len_x_s_t min(len_r, len_l) min len_r len_l idx = bisect.bisect_left(t, x) idx bisect.bisect_left(t, x) bisect.bisect_left bisect bisect_left t x len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF len_r t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF 0 <= idx < B 0 <= idx 0 idx B t[idx] - x + len_of_nearest_s[idx] t[idx] - x t[idx] t idx x len_of_nearest_s[idx] len_of_nearest_s idx INF len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF len_l x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF 0 <= idx - 1 < B 0 <= idx - 1 0 idx - 1 idx 1 B x - t[idx-1] + len_of_nearest_s[idx-1] x - t[idx-1] x t[idx-1] t idx-1 idx 1 len_of_nearest_s[idx-1] len_of_nearest_s idx-1 idx 1 INF len_x_t_s = min(len_r, len_l) len_x_t_s min(len_r, len_l) min len_r len_l print(min(len_x_s_t, len_x_t_s)) print min(len_x_s_t, len_x_t_s) min len_x_s_t len_x_t_s if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def F(): return float(input()) def F(): return float(input()) F def LI(): return [int(x) for x in input().split()] def LI(): return [int(x) for x in input().split()] LI def LSS(): return input().split() def LSS(): return input().split() LSS def LI_(): return [int(x)-1 for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] LI_ input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input INF = float('inf') float('inf') INF def SS(): return input() def SS(): return input() SS def I(): return int(input()) def I(): return int(input()) I def resolve():
    A, B, Q = LI()
    s = [I() for _ in range(A)]
    t = [I() for _ in range(B)]

    # xから一番近い神社に行く→その神社から一番近い寺に行く、またはその逆の2パターン

    # 各神社に対する一番近い寺の距離を求めておく
    len_of_nearest_t = [INF] * A
    for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
    len_of_nearest_s = [INF] * B
    for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

    for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s)) def resolve():
    A, B, Q = LI()
    s = [I() for _ in range(A)]
    t = [I() for _ in range(B)]

    # xから一番近い神社に行く→その神社から一番近い寺に行く、またはその逆の2パターン

    # 各神社に対する一番近い寺の距離を求めておく
    len_of_nearest_t = [INF] * A
    for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
    len_of_nearest_s = [INF] * B
    for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

    for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s)) resolve def LF(): return [float(x) for x in input().split()] def LF(): return [float(x) for x in input().split()] LF
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, Q = LI()
    s = [I() for _ in range(A)]
    t = [I() for _ in range(B)]

    # xから一番近い神社に行く→その神社から一番近い寺に行く、またはその逆の2パターン

    # 各神社に対する一番近い寺の距離を求めておく
    len_of_nearest_t = [INF] * A
    for i in range(A):
        idx = bisect.bisect_left(t, s[i])
        len_r = t[idx] - s[i] if 0 <= idx < B else INF
        len_l = s[i] - t[idx-1] if 0 <= idx - 1 < B else INF
        len_of_nearest_t[i] = min(len_l, len_r)
    # print(len_of_nearest_t)

    # 各寺に対する一番近い神社の距離を求めておく
    len_of_nearest_s = [INF] * B
    for i in range(B):
        idx = bisect.bisect_left(s, t[i])
        len_r = s[idx] - t[i] if 0 <= idx < A else INF
        len_l = t[i] - s[idx-1] if 0 <= idx - 1 < A else INF
        len_of_nearest_s[i] = min(len_l, len_r)
    # print(len_of_nearest_s)

    for _ in range(Q):
        x = I()
        # 神社→寺
        idx = bisect.bisect_left(s, x)
        len_r = s[idx] - x + len_of_nearest_t[idx] if 0 <= idx < A else INF
        len_l = x - s[idx-1] + len_of_nearest_t[idx-1] if 0 <= idx - 1 < A else INF
        len_x_s_t = min(len_r, len_l)
        # 寺→神社
        idx = bisect.bisect_left(t, x)
        len_r = t[idx] - x + len_of_nearest_s[idx] if 0 <= idx < B else INF
        len_l = x - t[idx-1] + len_of_nearest_s[idx-1] if 0 <= idx - 1 < B else INF
        len_x_t_s = min(len_r, len_l)
        print(min(len_x_s_t, len_x_t_s))

if __name__ == '__main__':
    resolve()
