from bisect import bisect_left as bl

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

inf = 10 ** 11

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

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

for _ in range(Q):

  x = int(eval(input()))

  b, d = bl(Sh, x), bl(Te, x)

  res = inf

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

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

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

      res = min(res, d1, d2)

  print(res)
import sys

from bisect import bisect_left as bl

input = sys.stdin.readline

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

a = [-10 ** 18] + [int(eval(input())) for _ in range(A)] + [10 ** 18]

b = [-10 ** 18] + [int(eval(input())) for _ in range(B)] + [10 ** 18]

for _ in range(Q):

  x = int(eval(input()))

  ra = bl(a, x)

  rb = bl(b, x)

  la = ra - 1

  lb = rb - 1

  res = 10 ** 18

  res = min(res, max(abs(a[ra] - x), abs(b[rb] - x)))

  res = min(res, max(abs(a[la] - x), abs(b[lb] - x)))

  res = min(res, max(abs(a[la] - x), abs(b[rb] - x)) + min(abs(a[la] - x), abs(b[rb] - x)) * 2)

  res = min(res, max(abs(a[ra] - x), abs(b[lb] - x)) + min(abs(a[ra] - x), abs(b[lb] - x)) * 2)

  print(res)
from bisect import bisect_left as bl

A, B, Q = list(map(int, input().split()))
inf = 10**11
Sh = [-1 * inf] + [int(eval(input())) for _ in range(A)] + [inf]
Te = [-1 * inf] + [int(eval(input())) for _ in range(B)] + [inf]
for _ in range(Q):
    x = int(eval(input()))
    b, d = bl(Sh, x), bl(Te, x)
    res = inf
    for S in [Sh[b - 1], Sh[b]]:
        for T in [Te[d - 1], Te[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

import sys
from bisect import bisect_left as bl

input = sys.stdin.readline
A, B, Q = list(map(int, input().split()))
a = [-(10**18)] + [int(eval(input())) for _ in range(A)] + [10**18]
b = [-(10**18)] + [int(eval(input())) for _ in range(B)] + [10**18]
for _ in range(Q):
    x = int(eval(input()))
    ra = bl(a, x)
    rb = bl(b, x)
    la = ra - 1
    lb = rb - 1
    res = 10**18
    res = min(res, max(abs(a[ra] - x), abs(b[rb] - x)))
    res = min(res, max(abs(a[la] - x), abs(b[lb] - x)))
    res = min(
        res,
        max(abs(a[la] - x), abs(b[rb] - x)) + min(abs(a[la] - x), abs(b[rb] - x)) * 2,
    )
    res = min(
        res,
        max(abs(a[ra] - x), abs(b[lb] - x)) + min(abs(a[ra] - x), abs(b[lb] - x)) * 2,
    )
    print(res)

+import sys +input = sys.stdin.readline -inf = 10**11 -Sh = [-1 * inf] + [int(eval(input())) for _ in range(A)] + [inf] -Te = [-1 * inf] + [int(eval(input())) for _ in range(B)] + [inf] +a = [-(10**18)] + [int(eval(input())) for _ in range(A)] + [10**18] +b = [-(10**18)] + [int(eval(input())) for _ in range(B)] + [10**18] -    b, d = bl(Sh, x), bl(Te, x) -    res = inf -    for S in [Sh[b - 1], Sh[b]]: -        for T in [Te[d - 1], Te[d]]: -            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) -            res = min(res, d1, d2) +    ra = bl(a, x) +    rb = bl(b, x) +    la = ra - 1 +    lb = rb - 1 +    res = 10**18 +    res = min(res, max(abs(a[ra] - x), abs(b[rb] - x))) +    res = min(res, max(abs(a[la] - x), abs(b[lb] - x))) +    res = min( +        res, +        max(abs(a[la] - x), abs(b[rb] - x)) + min(abs(a[la] - x), abs(b[rb] - x)) * 2, +    ) +    res = min( +        res, +        max(abs(a[ra] - x), abs(b[lb] - x)) + min(abs(a[ra] - x), abs(b[lb] - x)) * 2, +    )