from bisect import bisect_right


def main():
    a, b, q = map(int, input().split())
    s = [int(input()) for _ in range(a)]
    t = [int(input()) for _ in range(b)]
    neighbour_temple = [[] for _ in range(a)]
    for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
    for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans)


if __name__ == '__main__':
    main() from bisect import bisect_right def main():
    a, b, q = map(int, input().split())
    s = [int(input()) for _ in range(a)]
    t = [int(input()) for _ in range(b)]
    neighbour_temple = [[] for _ in range(a)]
    for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
    for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans) main 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)] [] for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) [] neighbour_temple = [[] for _ in range(a)] neighbour_temple [[] for _ in range(a)] for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
     i range(a) range a idx = bisect_right(t, s[i]) idx bisect_right(t, s[i]) bisect_right t s[i] s i if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
     idx == b idx b neighbour_temple[i].append(t[-1]) [i].append [i] neighbour_temple i append t[-1] t -1 if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
             idx > 0 idx 0 neighbour_temple[i].append(t[idx - 1]) [i].append [i] neighbour_temple i append t[idx - 1] t idx - 1 idx 1 neighbour_temple[i].append(t[idx]) [i].append [i] neighbour_temple i append t[idx] t idx for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans) _ range(q) range q begin = int(input()) begin int(input()) int input() input idx = bisect_right(s, begin) idx bisect_right(s, begin) bisect_right s begin visit_s = [] visit_s [] if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
         idx == a idx a visit_s.append(a - 1) visit_s.append visit_s append a - 1 a 1 if idx > 0:
                visit_s.append(idx - 1)
             idx > 0 idx 0 visit_s.append(idx - 1) visit_s.append visit_s append idx - 1 idx 1 visit_s.append(idx) visit_s.append visit_s append idx ans = float("inf") ans float("inf") float "inf" for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
         v_s visit_s for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
         v_t neighbour_temple[v_s] neighbour_temple v_s min_point = min(s[v_s], v_t) min_point min(s[v_s], v_t) min s[v_s] s v_s v_t large_point = max(s[v_s], v_t) large_point max(s[v_s], v_t) max s[v_s] s v_s v_t if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
         min_point <= begin <= large_point min_point <= begin min_point begin large_point ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin)) ans min(ans, large_point - min_point + min(begin - min_point, large_point - begin)) min ans large_point - min_point + min(begin - min_point, large_point - begin) large_point - min_point large_point min_point min(begin - min_point, large_point - begin) min begin - min_point begin min_point large_point - begin large_point begin elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                 begin <= min_point <= large_point begin <= min_point begin min_point large_point ans = min(ans, abs(large_point - begin)) ans min(ans, abs(large_point - begin)) min ans abs(large_point - begin) abs large_point - begin large_point begin ans = min(ans, abs(min_point - begin)) ans min(ans, abs(min_point - begin)) min ans abs(min_point - begin) abs min_point - begin min_point begin print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b, q = map(int, input().split())
    s = [int(input()) for _ in range(a)]
    t = [int(input()) for _ in range(b)]
    neighbour_temple = [[] for _ in range(a)]
    for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
    for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans) def main():
    a, b, q = map(int, input().split())
    s = [int(input()) for _ in range(a)]
    t = [int(input()) for _ in range(b)]
    neighbour_temple = [[] for _ in range(a)]
    for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
    for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans) main
from bisect import bisect_right


def main():
    a, b, q = map(int, input().split())
    s = [int(input()) for _ in range(a)]
    t = [int(input()) for _ in range(b)]
    neighbour_temple = [[] for _ in range(a)]
    for i in range(a):
        idx = bisect_right(t, s[i])
        if idx == b:
            neighbour_temple[i].append(t[-1])
        else:
            if idx > 0:
                neighbour_temple[i].append(t[idx - 1])
            neighbour_temple[i].append(t[idx])
    for _ in range(q):
        begin = int(input())
        idx = bisect_right(s, begin)
        visit_s = []
        if idx == a:
            visit_s.append(a - 1)
        else:
            if idx > 0:
                visit_s.append(idx - 1)
            visit_s.append(idx)
        ans = float("inf")
        for v_s in visit_s:
            for v_t in neighbour_temple[v_s]:
                min_point = min(s[v_s], v_t)
                large_point = max(s[v_s], v_t)
                if min_point <= begin <= large_point:
                    ans = min(ans, large_point - min_point + min(begin - min_point, large_point - begin))
                elif begin <= min_point <= large_point:
                    ans = min(ans, abs(large_point - begin))
                else:
                    ans = min(ans, abs(min_point - begin))
        print(ans)


if __name__ == '__main__':
    main()
