import itertools


def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist


def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper])


def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair))


if __name__ == '__main__':
    main() import itertools itertools def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist solve assert 2 == len(s_pair) == len(t_pair) 2 == len(s_pair) == len(t_pair) 2 == len(s_pair) 2 len(s_pair) len s_pair len(t_pair) len t_pair min_dist = 10**11 min_dist 10**11 10 11 for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
     s t itertools.product(s_pair, t_pair) itertools.product itertools product s_pair t_pair min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ]) min_dist min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ]) min [
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ] min_dist abs(x - s) + abs(s - t) abs(x - s) abs x - s x s abs(s - t) abs s - t s t abs(x - t) + abs(t - s) abs(x - t) abs x - t x t abs(t - s) abs t - s t s return min_dist min_dist x x s_pair s_pair t_pair t_pair def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper]) binary_search lower = 0 lower 0 upper = len(li) - 1 upper len(li) - 1 len(li) len li 1 while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
     abs(upper - lower) > 1 abs(upper - lower) abs upper - lower upper lower 1 mid = (lower + upper) // 2 mid (lower + upper) // 2 lower + upper lower upper 2 if li[mid] < x:
            lower = mid
        else:
            upper = mid
     li[mid] < x li[mid] li mid x lower = mid lower mid upper = mid upper mid return (li[lower], li[upper]) (li[lower], li[upper]) li[lower] li lower li[upper] li upper x x li li def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair)) main A, B, Q = list(map(int, input().split(' '))) A list(map(int, input().split(' '))) list 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_list = [int(input()) for _ in range(A)] s_list [int(input()) for _ in range(A)] s_list.sort() s_list.sort s_list sort int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t_list = [int(input()) for _ in range(B)] t_list [int(input()) for _ in range(B)] t_list.sort() t_list.sort t_list sort int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input x_list = [int(input()) for _ in range(Q)] x_list [int(input()) for _ in range(Q)] for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair)) x x_list s_pair = binary_search(x, s_list) s_pair binary_search(x, s_list) binary_search x s_list t_pair = binary_search(x, t_list) t_pair binary_search(x, t_list) binary_search x t_list print(solve(x, s_pair, t_pair)) print solve(x, s_pair, t_pair) solve x s_pair t_pair if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper]) def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper]) binary_search def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist solve def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair)) def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair)) main
import itertools


def solve(x, s_pair, t_pair):
    assert 2 == len(s_pair) == len(t_pair)
    min_dist = 10**11  # large number
    for s, t in itertools.product(s_pair, t_pair):
        min_dist = min([
            min_dist,
            abs(x - s) + abs(s - t),
            abs(x - t) + abs(t - s)
        ])
    return min_dist


def binary_search(x, li):
    lower = 0
    upper = len(li) - 1
    while abs(upper - lower) > 1:
        mid = (lower + upper) // 2
        if li[mid] < x:
            lower = mid
        else:
            upper = mid
    return (li[lower], li[upper])


def main():
    A, B, Q = list(map(int, input().split(' ')))
    s_list = [int(input()) for _ in range(A)]
    s_list.sort()
    t_list = [int(input()) for _ in range(B)]
    t_list.sort()
    x_list = [int(input()) for _ in range(Q)]
    for x in x_list:
        s_pair = binary_search(x, s_list)
        t_pair = binary_search(x, t_list)
        print(solve(x, s_pair, t_pair))


if __name__ == '__main__':
    main()