import sys
from bisect import bisect


def read():
    return sys.stdin.readline().rstrip()


def main():
    a, b, q = map(int, read().split())
    s = [-10**12] + [int(read()) for _ in range(a)] + [10**12]
    t = [-10**12] + [int(read()) for _ in range(b)] + [10**12]
    for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d)


if __name__ == '__main__':
    main() import sys sys from bisect import bisect def read():
    return sys.stdin.readline().rstrip() read return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    a, b, q = map(int, read().split())
    s = [-10**12] + [int(read()) for _ in range(a)] + [10**12]
    t = [-10**12] + [int(read()) for _ in range(b)] + [10**12]
    for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d) main a, b, q = map(int, read().split()) a map(int, read().split()) map int read().split() ().split () read split b q int(read()) for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) int(read()) int read() read s = [-10**12] + [int(read()) for _ in range(a)] + [10**12] s [-10**12] + [int(read()) for _ in range(a)] + [10**12] [-10**12] + [int(read()) for _ in range(a)] [-10**12] -10**12 -10 12 [int(read()) for _ in range(a)] [10**12] 10**12 10 12 int(read()) for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) int(read()) int read() read t = [-10**12] + [int(read()) for _ in range(b)] + [10**12] t [-10**12] + [int(read()) for _ in range(b)] + [10**12] [-10**12] + [int(read()) for _ in range(b)] [-10**12] -10**12 -10 12 [int(read()) for _ in range(b)] [10**12] 10**12 10 12 for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d) _ range(q) range q x = int(read()) x int(read()) int read() read si = bisect(s, x) si bisect(s, x) bisect s x ti = bisect(t, x) ti bisect(t, x) bisect t x sa, sb = s[si - 1], s[si] sa s[si - 1] s si - 1 si 1 sb s[si] s si ta, tb = t[ti - 1], t[ti] ta t[ti - 1] t ti - 1 ti 1 tb t[ti] t ti d = 10**12 d 10**12 10 12 for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
         sx (sa, sb) sa sb for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
         tx (ta, tb) ta tb d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d) d min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d) min abs(x - sx) + abs(sx - tx) abs(x - sx) abs x - sx x sx abs(sx - tx) abs sx - tx sx tx abs(x - tx) + abs(tx - sx) abs(x - tx) abs x - tx x tx abs(tx - sx) abs tx - sx tx sx d print(d) print d if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def read():
    return sys.stdin.readline().rstrip() def read():
    return sys.stdin.readline().rstrip() read def main():
    a, b, q = map(int, read().split())
    s = [-10**12] + [int(read()) for _ in range(a)] + [10**12]
    t = [-10**12] + [int(read()) for _ in range(b)] + [10**12]
    for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d) def main():
    a, b, q = map(int, read().split())
    s = [-10**12] + [int(read()) for _ in range(a)] + [10**12]
    t = [-10**12] + [int(read()) for _ in range(b)] + [10**12]
    for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d) main
import sys
from bisect import bisect


def read():
    return sys.stdin.readline().rstrip()


def main():
    a, b, q = map(int, read().split())
    s = [-10**12] + [int(read()) for _ in range(a)] + [10**12]
    t = [-10**12] + [int(read()) for _ in range(b)] + [10**12]
    for _ in range(q):
        x = int(read())
        si = bisect(s, x)
        ti = bisect(t, x)
        sa, sb = s[si - 1], s[si]
        ta, tb = t[ti - 1], t[ti]
        d = 10**12
        for sx in (sa, sb):
            for tx in (ta, tb):
                d = min(abs(x - sx) + abs(sx - tx), abs(x - tx) + abs(tx - sx), d)
        print(d)


if __name__ == '__main__':
    main()
