import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, q = list(map(int, readline().split()))
    s = [0] * (a + 2)
    t = [0] * (b + 2)
    d = [0] * (a + b + 2)

    for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

    s[0] = -INF
    s[a + 1] = INF

    for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

    t[0] = -INF
    t[b + 1] = INF

    d[0] = (-INF, 0)
    d[-1] = (INF, 0)

    d.sort()
    d2 = [k[0] for k in d]
    import bisect

    for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right))


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    a, b, q = list(map(int, readline().split()))
    s = [0] * (a + 2)
    t = [0] * (b + 2)
    d = [0] * (a + b + 2)

    for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

    s[0] = -INF
    s[a + 1] = INF

    for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

    t[0] = -INF
    t[b + 1] = INF

    d[0] = (-INF, 0)
    d[-1] = (INF, 0)

    d.sort()
    d2 = [k[0] for k in d]
    import bisect

    for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right)) main a, b, q = list(map(int, readline().split())) a list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split b q s = [0] * (a + 2) s [0] * (a + 2) [0] 0 a + 2 a 2 t = [0] * (b + 2) t [0] * (b + 2) [0] 0 b + 2 b 2 d = [0] * (a + b + 2) d [0] * (a + b + 2) [0] 0 a + b + 2 a + b a b 2 for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

     i range(1, a + 1) range 1 a + 1 a 1 dist = int(input()) dist int(input()) int input() input s[i] = dist s[i] s i dist d[i] = (dist, 0) d[i] d i (dist, 0) dist 0 s[0] = -INF s[0] s 0 -INF INF s[a + 1] = INF s[a + 1] s a + 1 a 1 INF for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

     i range(1, b + 1) range 1 b + 1 b 1 dist = int(input()) dist int(input()) int input() input t[i] = dist t[i] t i dist d[a + i] = (dist, 1) d[a + i] d a + i a i (dist, 1) dist 1 t[0] = -INF t[0] t 0 -INF INF t[b + 1] = INF t[b + 1] t b + 1 b 1 INF d[0] = (-INF, 0) d[0] d 0 (-INF, 0) -INF INF 0 d[-1] = (INF, 0) d[-1] d -1 (INF, 0) INF 0 d.sort() d.sort d sort k[0] for k in d for k in d k d for k in d k[0] k 0 d2 = [k[0] for k in d] d2 [k[0] for k in d] import bisect bisect for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right)) _ range(q) range q x = int(input()) x int(input()) int input() input d_idx = bisect.bisect_left(d2, x) d_idx bisect.bisect_left(d2, x) bisect.bisect_left bisect bisect_left d2 x left = d[d_idx - 1] left d[d_idx - 1] d d_idx - 1 d_idx 1 right = d[d_idx] right d[d_idx] d d_idx res_left = x - left[0] res_left x - left[0] x left[0] left 0 res_right = right[0] - x res_right right[0] - x right[0] right 0 x if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

         left[1] == 0 left[1] left 1 0 t_idx = bisect.bisect_left(t, left[0]) t_idx bisect.bisect_left(t, left[0]) bisect.bisect_left bisect bisect_left t left[0] left 0 tl = t[t_idx - 1] tl t[t_idx - 1] t t_idx - 1 t_idx 1 tr = t[t_idx] tr t[t_idx] t t_idx res_left += min(abs(left[0] - tl), abs(tr - left[0])) res_left min(abs(left[0] - tl), abs(tr - left[0])) min abs(left[0] - tl) abs left[0] - tl left[0] left 0 tl abs(tr - left[0]) abs tr - left[0] tr left[0] left 0 s_idx = bisect.bisect_left(s, left[0]) s_idx bisect.bisect_left(s, left[0]) bisect.bisect_left bisect bisect_left s left[0] left 0 sl = s[s_idx - 1] sl s[s_idx - 1] s s_idx - 1 s_idx 1 sr = s[s_idx] sr s[s_idx] s s_idx res_left += min(abs(left[0] - sl), abs(sr - left[0])) res_left min(abs(left[0] - sl), abs(sr - left[0])) min abs(left[0] - sl) abs left[0] - sl left[0] left 0 sl abs(sr - left[0]) abs sr - left[0] sr left[0] left 0 if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
         right[1] == 0 right[1] right 1 0 t_idx = bisect.bisect_left(t, right[0]) t_idx bisect.bisect_left(t, right[0]) bisect.bisect_left bisect bisect_left t right[0] right 0 tl = t[t_idx - 1] tl t[t_idx - 1] t t_idx - 1 t_idx 1 tr = t[t_idx] tr t[t_idx] t t_idx res_right += min(abs(right[0] - tl), abs(tr - right[0])) res_right min(abs(right[0] - tl), abs(tr - right[0])) min abs(right[0] - tl) abs right[0] - tl right[0] right 0 tl abs(tr - right[0]) abs tr - right[0] tr right[0] right 0 s_idx = bisect.bisect_left(s, right[0]) s_idx bisect.bisect_left(s, right[0]) bisect.bisect_left bisect bisect_left s right[0] right 0 sl = s[s_idx - 1] sl s[s_idx - 1] s s_idx - 1 s_idx 1 sr = s[s_idx] sr s[s_idx] s s_idx res_right += min(abs(right[0] - sl), abs(sr - right[0])) res_right min(abs(right[0] - sl), abs(sr - right[0])) min abs(right[0] - sl) abs right[0] - sl right[0] right 0 sl abs(sr - right[0]) abs sr - right[0] sr right[0] right 0 print(min(res_left, res_right)) print min(res_left, res_right) min res_left res_right if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = float('INF') float('INF') INF readline = sys.stdin.readline sys.stdin.readline readline def main():
    a, b, q = list(map(int, readline().split()))
    s = [0] * (a + 2)
    t = [0] * (b + 2)
    d = [0] * (a + b + 2)

    for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

    s[0] = -INF
    s[a + 1] = INF

    for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

    t[0] = -INF
    t[b + 1] = INF

    d[0] = (-INF, 0)
    d[-1] = (INF, 0)

    d.sort()
    d2 = [k[0] for k in d]
    import bisect

    for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right)) def main():
    a, b, q = list(map(int, readline().split()))
    s = [0] * (a + 2)
    t = [0] * (b + 2)
    d = [0] * (a + b + 2)

    for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

    s[0] = -INF
    s[a + 1] = INF

    for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

    t[0] = -INF
    t[b + 1] = INF

    d[0] = (-INF, 0)
    d[-1] = (INF, 0)

    d.sort()
    d2 = [k[0] for k in d]
    import bisect

    for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right)) main
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, q = list(map(int, readline().split()))
    s = [0] * (a + 2)
    t = [0] * (b + 2)
    d = [0] * (a + b + 2)

    for i in range(1, a + 1):
        dist = int(input())
        s[i] = dist
        d[i] = (dist, 0)

    s[0] = -INF
    s[a + 1] = INF

    for i in range(1, b + 1):
        dist = int(input())
        t[i] = dist
        d[a + i] = (dist, 1)

    t[0] = -INF
    t[b + 1] = INF

    d[0] = (-INF, 0)
    d[-1] = (INF, 0)

    d.sort()
    d2 = [k[0] for k in d]
    import bisect

    for _ in range(q):
        x = int(input())
        d_idx = bisect.bisect_left(d2, x)
        left = d[d_idx - 1]
        right = d[d_idx]
        res_left = x - left[0]
        res_right = right[0] - x

        if left[1] == 0:
            t_idx = bisect.bisect_left(t, left[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_left += min(abs(left[0] - tl), abs(tr - left[0]))
        else:
            s_idx = bisect.bisect_left(s, left[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_left += min(abs(left[0] - sl), abs(sr - left[0]))

        if right[1] == 0:
            t_idx = bisect.bisect_left(t, right[0])
            tl = t[t_idx - 1]
            tr = t[t_idx]
            res_right += min(abs(right[0] - tl), abs(tr - right[0]))
        else:
            s_idx = bisect.bisect_left(s, right[0])
            sl = s[s_idx - 1]
            sr = s[s_idx]
            res_right += min(abs(right[0] - sl), abs(sr - right[0]))
        print(min(res_left, res_right))


if __name__ == '__main__':
    main()
