from bisect import bisect

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

S, T =[None] * (A+2), [None] * (B+2)

S[0], T[0] = -10**20, -10**20

for i in range(A):

    S[i+1] = int(eval(input()))

for i in range(B):

    T[i+1] = int(eval(input()))

S[A+1] = 10**20

T[B+1] = 10**20



lenS, lenT = len(S), len(T)

for _ in range(Q):

    x = int(eval(input()))

    si, ti = bisect(S, x, 0, lenS), bisect(T, x, 0, lenT)

    sLength0, sLength1 = x - S[si-1], S[si] - x

    tLength0, tLength1 = x - T[ti-1], T[ti] - x

    Ans = (max(sLength0, tLength0), max(sLength1, tLength1), sLength0 + tLength1 + min(sLength0, tLength1), sLength1 + tLength0 + min(sLength1, tLength0))

    print((min(Ans)))
import sys

from bisect import bisect

F = sys.stdin

A, B, Q = list(map(int, F.readline().strip("\n").split(" ")))

S, T =[None] * (A+2), [None] * (B+2)

S[0], T[0] = -10**20, -10**20

for i in range(A):

    S[i+1] = int(F.readline().strip("\n"))

for i in range(B):

    T[i+1] = int(F.readline().strip("\n"))

S[A+1] = 10**20

T[B+1] = 10**20



lenS, lenT = len(S), len(T)

for _ in range(Q):

    x = int(F.readline().strip("\n"))

    si, ti = bisect(S, x, 0, lenS), bisect(T, x, 0, lenT)

    sLength0, sLength1 = x - S[si-1], S[si] - x

    tLength0, tLength1 = x - T[ti-1], T[ti] - x

    Ans = (max(sLength0, tLength0), max(sLength1, tLength1), sLength0 + tLength1 + min(sLength0, tLength1), sLength1 + tLength0 + min(sLength1, tLength0))

    print((min(Ans)))
from bisect import bisect

A, B, Q = list(map(int, input().split()))
S, T = [None] * (A + 2), [None] * (B + 2)
S[0], T[0] = -(10**20), -(10**20)
for i in range(A):
    S[i + 1] = int(eval(input()))
for i in range(B):
    T[i + 1] = int(eval(input()))
S[A + 1] = 10**20
T[B + 1] = 10**20
lenS, lenT = len(S), len(T)
for _ in range(Q):
    x = int(eval(input()))
    si, ti = bisect(S, x, 0, lenS), bisect(T, x, 0, lenT)
    sLength0, sLength1 = x - S[si - 1], S[si] - x
    tLength0, tLength1 = x - T[ti - 1], T[ti] - x
    Ans = (
        max(sLength0, tLength0),
        max(sLength1, tLength1),
        sLength0 + tLength1 + min(sLength0, tLength1),
        sLength1 + tLength0 + min(sLength1, tLength0),
    )
    print((min(Ans)))

import sys
from bisect import bisect

F = sys.stdin
A, B, Q = list(map(int, F.readline().strip("\n").split(" ")))
S, T = [None] * (A + 2), [None] * (B + 2)
S[0], T[0] = -(10**20), -(10**20)
for i in range(A):
    S[i + 1] = int(F.readline().strip("\n"))
for i in range(B):
    T[i + 1] = int(F.readline().strip("\n"))
S[A + 1] = 10**20
T[B + 1] = 10**20
lenS, lenT = len(S), len(T)
for _ in range(Q):
    x = int(F.readline().strip("\n"))
    si, ti = bisect(S, x, 0, lenS), bisect(T, x, 0, lenT)
    sLength0, sLength1 = x - S[si - 1], S[si] - x
    tLength0, tLength1 = x - T[ti - 1], T[ti] - x
    Ans = (
        max(sLength0, tLength0),
        max(sLength1, tLength1),
        sLength0 + tLength1 + min(sLength0, tLength1),
        sLength1 + tLength0 + min(sLength1, tLength0),
    )
    print((min(Ans)))

+import sys -A, B, Q = list(map(int, input().split())) +F = sys.stdin +A, B, Q = list(map(int, F.readline().strip("\n").split(" "))) -    S[i + 1] = int(eval(input())) +    S[i + 1] = int(F.readline().strip("\n")) -    T[i + 1] = int(eval(input())) +    T[i + 1] = int(F.readline().strip("\n")) -    x = int(eval(input())) +    x = int(F.readline().strip("\n"))