#!/usr/bin/env python

# coding: utf-8





inf = float('inf')



def main():

    A, B, Q = list(map(int, input().split()))

    ls = []

    lt = []

    lx = []

    for _ in range(A):

        ls.append(int(eval(input())))

    for _ in range(B):

        lt.append(int(eval(input())))

    for i in range(Q):

        lx.append((int(eval(input())), i))

    ls.sort()

    lt.sort()

    lx.sort()

    ans = {}

    s = 0

    t = 0

    for i in range(Q):

        dist = -1

        x = lx[i][0]

        while s < A and ls[s] < x:

            s += 1

        while t < B and lt[t] < x:

            t += 1

        s_min = ls[s-1] if s > 0 else ls[0]

        s_max = ls[s] if s < A else ls[s-1]

        t_min = lt[t-1] if t > 0 else lt[0]

        t_max = lt[t] if t < B else lt[t-1]

        if s_min > x:

            s_min = -inf

        if t_min > x:

            t_min = -inf

        if s_max < x:

            s_max = inf

        if t_max < x:

            t_max = inf

        assert(t_max > x)

        assert(s_max > x)

        assert(t_min < x)

        assert(s_min < x)

        d = min(max(s_max-x, t_max-x),

                (s_max-x)*2 + (x-t_min),

                (t_max-x)*2 + (x-s_min),

                (s_max-x) + (x-t_min)*2,

                (t_max-x) + (x-s_min)*2,

                max(x-s_min,x-t_min))

        ans[lx[i][1]] = d

    for i in range(Q):

        print((ans[i]))





if __name__ == '__main__':

    main()

#!/usr/bin/env python

# coding: utf-8



import sys

input = sys.stdin.readline



inf = float('inf')



def main():

    A, B, Q = list(map(int, input().split()))

    ls = [-inf] + [int(eval(input())) for _ in range(A)] + [inf]

    lt = [-inf] + [int(eval(input())) for _ in range(B)] + [inf]

    lx = [(int(eval(input())), i) for i in range(Q)]

    ls.sort()

    lt.sort()

    lx.sort()

    ans = {}

    s = 1

    t = 1

    for i in range(Q):

        dist = -1

        x = lx[i][0]

        while s <= A and ls[s] < x:

            s += 1

        while t <= B and lt[t] < x:

            t += 1

        s_min = ls[s-1]

        s_max = ls[s]

        t_min = lt[t-1]

        t_max = lt[t]

        d = min(max(s_max-x, t_max-x),

                (s_max-x)*2 + (x-t_min),

                (t_max-x)*2 + (x-s_min),

                (s_max-x) + (x-t_min)*2,

                (t_max-x) + (x-s_min)*2,

                max(x-s_min,x-t_min))

        ans[lx[i][1]] = d

    for i in range(Q):

        print((ans[i]))





if __name__ == '__main__':

    main()

#!/usr/bin/env python
# coding: utf-8
inf = float("inf")


def main():
    A, B, Q = list(map(int, input().split()))
    ls = []
    lt = []
    lx = []
    for _ in range(A):
        ls.append(int(eval(input())))
    for _ in range(B):
        lt.append(int(eval(input())))
    for i in range(Q):
        lx.append((int(eval(input())), i))
    ls.sort()
    lt.sort()
    lx.sort()
    ans = {}
    s = 0
    t = 0
    for i in range(Q):
        dist = -1
        x = lx[i][0]
        while s < A and ls[s] < x:
            s += 1
        while t < B and lt[t] < x:
            t += 1
        s_min = ls[s - 1] if s > 0 else ls[0]
        s_max = ls[s] if s < A else ls[s - 1]
        t_min = lt[t - 1] if t > 0 else lt[0]
        t_max = lt[t] if t < B else lt[t - 1]
        if s_min > x:
            s_min = -inf
        if t_min > x:
            t_min = -inf
        if s_max < x:
            s_max = inf
        if t_max < x:
            t_max = inf
        assert t_max > x
        assert s_max > x
        assert t_min < x
        assert s_min < x
        d = min(
            max(s_max - x, t_max - x),
            (s_max - x) * 2 + (x - t_min),
            (t_max - x) * 2 + (x - s_min),
            (s_max - x) + (x - t_min) * 2,
            (t_max - x) + (x - s_min) * 2,
            max(x - s_min, x - t_min),
        )
        ans[lx[i][1]] = d
    for i in range(Q):
        print((ans[i]))


if __name__ == "__main__":
    main()

#!/usr/bin/env python
# coding: utf-8
import sys

input = sys.stdin.readline
inf = float("inf")


def main():
    A, B, Q = list(map(int, input().split()))
    ls = [-inf] + [int(eval(input())) for _ in range(A)] + [inf]
    lt = [-inf] + [int(eval(input())) for _ in range(B)] + [inf]
    lx = [(int(eval(input())), i) for i in range(Q)]
    ls.sort()
    lt.sort()
    lx.sort()
    ans = {}
    s = 1
    t = 1
    for i in range(Q):
        dist = -1
        x = lx[i][0]
        while s <= A and ls[s] < x:
            s += 1
        while t <= B and lt[t] < x:
            t += 1
        s_min = ls[s - 1]
        s_max = ls[s]
        t_min = lt[t - 1]
        t_max = lt[t]
        d = min(
            max(s_max - x, t_max - x),
            (s_max - x) * 2 + (x - t_min),
            (t_max - x) * 2 + (x - s_min),
            (s_max - x) + (x - t_min) * 2,
            (t_max - x) + (x - s_min) * 2,
            max(x - s_min, x - t_min),
        )
        ans[lx[i][1]] = d
    for i in range(Q):
        print((ans[i]))


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline -    ls = [] -    lt = [] -    lx = [] -    for _ in range(A): -        ls.append(int(eval(input()))) -    for _ in range(B): -        lt.append(int(eval(input()))) -    for i in range(Q): -        lx.append((int(eval(input())), i)) +    ls = [-inf] + [int(eval(input())) for _ in range(A)] + [inf] +    lt = [-inf] + [int(eval(input())) for _ in range(B)] + [inf] +    lx = [(int(eval(input())), i) for i in range(Q)] -    s = 0 -    t = 0 +    s = 1 +    t = 1 -        while s < A and ls[s] < x: +        while s <= A and ls[s] < x: -        while t < B and lt[t] < x: +        while t <= B and lt[t] < x: -        s_min = ls[s - 1] if s > 0 else ls[0] -        s_max = ls[s] if s < A else ls[s - 1] -        t_min = lt[t - 1] if t > 0 else lt[0] -        t_max = lt[t] if t < B else lt[t - 1] -        if s_min > x: -            s_min = -inf -        if t_min > x: -            t_min = -inf -        if s_max < x: -            s_max = inf -        if t_max < x: -            t_max = inf -        assert t_max > x -        assert s_max > x -        assert t_min < x -        assert s_min < x +        s_min = ls[s - 1] +        s_max = ls[s] +        t_min = lt[t - 1] +        t_max = lt[t]