import bisect

a,b,q = map(int,input().split())
shrine = [-10**12, 10**12]
for _ in range(a):
    s = int(input())
    shrine.append(s)
shrine.sort()

temple = [-10**12, 10**12]
for _ in range(b):
    t = int(input())
    temple.append(t)
temple.sort()

for _ in range(q):
    x = int(input())
    sx = bisect.bisect_right(shrine,x)
    tx = bisect.bisect_right(temple,x)
    ans = 10**12
    #最適な経路はスタート地点から前後のshrine、templeを訪れる経路
    for i in [shrine[sx-1], shrine[sx]]:
        for j in [temple[tx-1], temple[tx]]:
            #caas_1はスタート→shrine→temple
            case_1 = abs(i-x)+abs(i-j)
            #caas_2はスタート→temple→shrine
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
    print(ans) import bisect bisect a,b,q = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b q shrine = [-10**12, 10**12] shrine [-10**12, 10**12] -10**12 -10 12 10**12 10 12 for _ in range(a):
    s = int(input())
    shrine.append(s) _ range(a) range a s = int(input()) s int(input()) int input() input shrine.append(s) shrine.append shrine append s shrine.sort() shrine.sort shrine sort temple = [-10**12, 10**12] temple [-10**12, 10**12] -10**12 -10 12 10**12 10 12 for _ in range(b):
    t = int(input())
    temple.append(t) _ range(b) range b t = int(input()) t int(input()) int input() input temple.append(t) temple.append temple append t temple.sort() temple.sort temple sort for _ in range(q):
    x = int(input())
    sx = bisect.bisect_right(shrine,x)
    tx = bisect.bisect_right(temple,x)
    ans = 10**12
    #最適な経路はスタート地点から前後のshrine、templeを訪れる経路
    for i in [shrine[sx-1], shrine[sx]]:
        for j in [temple[tx-1], temple[tx]]:
            #caas_1はスタート→shrine→temple
            case_1 = abs(i-x)+abs(i-j)
            #caas_2はスタート→temple→shrine
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
    print(ans) _ range(q) range q x = int(input()) x int(input()) int input() input sx = bisect.bisect_right(shrine,x) sx bisect.bisect_right(shrine,x) bisect.bisect_right bisect bisect_right shrine x tx = bisect.bisect_right(temple,x) tx bisect.bisect_right(temple,x) bisect.bisect_right bisect bisect_right temple x ans = 10**12 ans 10**12 10 12 for i in [shrine[sx-1], shrine[sx]]:
        for j in [temple[tx-1], temple[tx]]:
            #caas_1はスタート→shrine→temple
            case_1 = abs(i-x)+abs(i-j)
            #caas_2はスタート→temple→shrine
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
     i [shrine[sx-1], shrine[sx]] shrine[sx-1] shrine sx-1 sx 1 shrine[sx] shrine sx for j in [temple[tx-1], temple[tx]]:
            #caas_1はスタート→shrine→temple
            case_1 = abs(i-x)+abs(i-j)
            #caas_2はスタート→temple→shrine
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
     j [temple[tx-1], temple[tx]] temple[tx-1] temple tx-1 tx 1 temple[tx] temple tx case_1 = abs(i-x)+abs(i-j) case_1 abs(i-x)+abs(i-j) abs(i-x) abs i-x i x abs(i-j) abs i-j i j case_2 = abs(j-x)+abs(i-j) case_2 abs(j-x)+abs(i-j) abs(j-x) abs j-x j x abs(i-j) abs i-j i j ans = min(ans,case_1,case_2) ans min(ans,case_1,case_2) min ans case_1 case_2 print(ans) print ans temple = [-10**12, 10**12] [-10**12, 10**12] temple sx = bisect.bisect_right(shrine,x) bisect.bisect_right(shrine,x) sx case_2 = abs(j-x)+abs(i-j) abs(j-x)+abs(i-j) case_2 b,q = map(int,input().split()) map(int,input().split()) b tx = bisect.bisect_right(temple,x) bisect.bisect_right(temple,x) tx case_1 = abs(i-x)+abs(i-j) abs(i-x)+abs(i-j) case_1 s = int(input()) int(input()) s shrine = [-10**12, 10**12] [-10**12, 10**12] shrine ans = min(ans,case_1,case_2) min(ans,case_1,case_2) ans x = int(input()) int(input()) x ans = 10**12 10**12 ans a,b,q = map(int,input().split()) map(int,input().split()) a q = map(int,input().split()) map(int,input().split()) q t = int(input()) int(input()) t
import bisect

a,b,q = map(int,input().split())
shrine = [-10**12, 10**12]
for _ in range(a):
    s = int(input())
    shrine.append(s)
shrine.sort()

temple = [-10**12, 10**12]
for _ in range(b):
    t = int(input())
    temple.append(t)
temple.sort()

for _ in range(q):
    x = int(input())
    sx = bisect.bisect_right(shrine,x)
    tx = bisect.bisect_right(temple,x)
    ans = 10**12
    #最適な経路はスタート地点から前後のshrine、templeを訪れる経路
    for i in [shrine[sx-1], shrine[sx]]:
        for j in [temple[tx-1], temple[tx]]:
            #caas_1はスタート→shrine→temple
            case_1 = abs(i-x)+abs(i-j)
            #caas_2はスタート→temple→shrine
            case_2 = abs(j-x)+abs(i-j)
            ans = min(ans,case_1,case_2)
            
    print(ans)