from bisect import bisect_left
def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res)
main() from bisect import bisect_left def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res) main A, B, q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B q INF = 10**18 INF 10**18 10 18 int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input s = [-INF] + [int(input()) for _ in range(A)] + [INF] s [-INF] + [int(input()) for _ in range(A)] + [INF] [-INF] + [int(input()) for _ in range(A)] [-INF] -INF INF [int(input()) for _ in range(A)] [INF] INF int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t = [-INF] + [int(input()) for _ in range(B)] + [INF] t [-INF] + [int(input()) for _ in range(B)] + [INF] [-INF] + [int(input()) for _ in range(B)] [-INF] -INF INF [int(input()) for _ in range(B)] [INF] INF for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res) _ range(q) range q x = int(input()) x int(input()) int input() input sind = bisect_left(s, x) sind bisect_left(s, x) bisect_left s x tind = bisect_left(t, x) tind bisect_left(t, x) bisect_left t x res = INF res INF for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
         S [s[sind-1], s[sind]] s[sind-1] s sind-1 sind 1 s[sind] s sind for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
         T [t[tind-1], t[tind]] t[tind-1] t tind-1 tind 1 t[tind] t tind d1 = abs(x-S) + abs(S-T) d1 abs(x-S) + abs(S-T) abs(x-S) abs x-S x S abs(S-T) abs S-T S T d2 = abs(x-T) + abs(T-S) d2 abs(x-T) + abs(T-S) abs(x-T) abs x-T x T abs(T-S) abs T-S T S res = min([res, d1, d2]) res min([res, d1, d2]) min [res, d1, d2] res d1 d2 print(res) print res main() main def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res) def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res) main
from bisect import bisect_left
def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res)
main()