import bisect

from scipy.sparse.csgraph import floyd_warshall as wf

INF = 10**20



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

s = [-INF]+[int(eval(input())) for _ in range(A)]+[INF]

t = [-INF]+[int(eval(input())) for _ in range(B)]+[INF]



for i in range(Q):

    q = int(eval(input()))

    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)

    ans = INF

    for S in [s[b-1],s[b]]:

        for T in [t[d-1],t[d]]:

            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)

            ans = min(ans,d1,d2)

    print(ans)
import sys

import itertools

import math

from collections import deque

from collections import defaultdict

from itertools import permutations

import heapq

import bisect

from scipy.sparse.csgraph import floyd_warshall as wf

INF = 10**20



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

s = [-INF]+list(map(int, (sys.stdin.readline() for _ in [0]*A)))+[INF]

t = [-INF]+list(map(int, (sys.stdin.readline() for _ in [0]*B)))+[INF]

queries=list(map(int,sys.stdin))

for q in queries:

    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)

    ans = INF

    for S in [s[b-1],s[b]]:

        for T in [t[d-1],t[d]]:

            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)

            ans = min(ans,d1,d2)

    print(ans)
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf

INF = 10**20
A, B, Q = list(map(int, input().split()))
s = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for _ in range(B)] + [INF]
for i in range(Q):
    q = int(eval(input()))
    b, d = bisect.bisect_right(s, q), bisect.bisect_right(t, q)
    ans = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - q) + abs(T - S), abs(T - q) + abs(S - T)
            ans = min(ans, d1, d2)
    print(ans)

import sys
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf

INF = 10**20
A, B, Q = list(map(int, input().split()))
s = [-INF] + list(map(int, (sys.stdin.readline() for _ in [0] * A))) + [INF]
t = [-INF] + list(map(int, (sys.stdin.readline() for _ in [0] * B))) + [INF]
queries = list(map(int, sys.stdin))
for q in queries:
    b, d = bisect.bisect_right(s, q), bisect.bisect_right(t, q)
    ans = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - q) + abs(T - S), abs(T - q) + abs(S - T)
            ans = min(ans, d1, d2)
    print(ans)

+import sys +import itertools +import math +from collections import deque +from collections import defaultdict +from itertools import permutations +import heapq -s = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] -t = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] -for i in range(Q): -    q = int(eval(input())) +s = [-INF] + list(map(int, (sys.stdin.readline() for _ in [0] * A))) + [INF] +t = [-INF] + list(map(int, (sys.stdin.readline() for _ in [0] * B))) + [INF] +queries = list(map(int, sys.stdin)) +for q in queries: