a,b,q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
#print(s)
#print(t)
#print(x)
from bisect import bisect_left

def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret

for i in range(q):
    xi = x[i]
    ans = 10 ** 15
    # sから先
    ans = min(ans, search_st(xi, s, t))
    ans = min(ans, search_st(xi, t, s))
    print(ans) a,b,q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(input()) int input() input s = [int(input()) for _ in range(a)] s [int(input()) for _ in range(a)] int(input()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(input()) int input() input t = [int(input()) for _ in range(b)] t [int(input()) for _ in range(b)] int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input x = [int(input()) for _ in range(q)] x [int(input()) for _ in range(q)] s.sort() s.sort s sort t.sort() t.sort t sort from bisect import bisect_left def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret search_st ret = 10 ** 15 ret 10 ** 15 10 15 ls = len(s) ls len(s) len s lt = len(t) lt len(t) len t ss = bisect_left(s, xi) ss bisect_left(s, xi) bisect_left s xi si = s[ss % ls] si s[ss % ls] s ss % ls ss ls st = bisect_left(t, si) st bisect_left(t, si) bisect_left t si ti = t[st % lt] ti t[st % lt] t st % lt st lt ret = min(ret, abs(xi - si) + abs(si - ti)) ret min(ret, abs(xi - si) + abs(si - ti)) min ret abs(xi - si) + abs(si - ti) abs(xi - si) abs xi - si xi si abs(si - ti) abs si - ti si ti st -= 1 st 1 ti = t[st % lt] ti t[st % lt] t st % lt st lt ret = min(ret, abs(xi - si) + abs(si - ti)) ret min(ret, abs(xi - si) + abs(si - ti)) min ret abs(xi - si) + abs(si - ti) abs(xi - si) abs xi - si xi si abs(si - ti) abs si - ti si ti ss -= 1 ss 1 si = s[ss % ls] si s[ss % ls] s ss % ls ss ls st = bisect_left(t, si) st bisect_left(t, si) bisect_left t si ti = t[st % lt] ti t[st % lt] t st % lt st lt ret = min(ret, abs(xi - si) + abs(si - ti)) ret min(ret, abs(xi - si) + abs(si - ti)) min ret abs(xi - si) + abs(si - ti) abs(xi - si) abs xi - si xi si abs(si - ti) abs si - ti si ti st -= 1 st 1 ti = t[st % lt] ti t[st % lt] t st % lt st lt ret = min(ret, abs(xi - si) + abs(si - ti)) ret min(ret, abs(xi - si) + abs(si - ti)) min ret abs(xi - si) + abs(si - ti) abs(xi - si) abs xi - si xi si abs(si - ti) abs si - ti si ti return ret ret xi xi s s t t for i in range(q):
    xi = x[i]
    ans = 10 ** 15
    # sから先
    ans = min(ans, search_st(xi, s, t))
    ans = min(ans, search_st(xi, t, s))
    print(ans) i range(q) range q xi = x[i] xi x[i] x i ans = 10 ** 15 ans 10 ** 15 10 15 ans = min(ans, search_st(xi, s, t)) ans min(ans, search_st(xi, s, t)) min ans search_st(xi, s, t) search_st xi s t ans = min(ans, search_st(xi, t, s)) ans min(ans, search_st(xi, t, s)) min ans search_st(xi, t, s) search_st xi t s print(ans) print ans b,q = map(int, input().split()) map(int, input().split()) b q = map(int, input().split()) map(int, input().split()) q s = [int(input()) for _ in range(a)] [int(input()) for _ in range(a)] s ans = min(ans, search_st(xi, t, s)) min(ans, search_st(xi, t, s)) ans xi = x[i] x[i] xi def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret search_st ans = min(ans, search_st(xi, s, t)) min(ans, search_st(xi, s, t)) ans a,b,q = map(int, input().split()) map(int, input().split()) a t = [int(input()) for _ in range(b)] [int(input()) for _ in range(b)] t x = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] x ans = 10 ** 15 10 ** 15 ans
a,b,q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
#print(s)
#print(t)
#print(x)
from bisect import bisect_left

def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret

for i in range(q):
    xi = x[i]
    ans = 10 ** 15
    # sから先
    ans = min(ans, search_st(xi, s, t))
    ans = min(ans, search_st(xi, t, s))
    print(ans)
