import bisect

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

INF = 10 ** 18

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

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

for q in range(Q):

  x = int(eval(input()))

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

  res = INF

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

    for T in [t[d - 1], t[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

a,b,q = list(map(int, sys.stdin.readline().split()))

S = []

for _ in range(a):

  S.append(int(sys.stdin.readline()))

T = []

for _ in range(b):

  T.append(int(sys.stdin.readline()))

X = []

for _ in range(q):

  X.append(int(sys.stdin.readline()))



INF = 10 ** 11

def dfs(direction, tors, pos, count):

  if tors == 1:

    L = T

  elif tors == -1:

    L = S

  i = bisect_left(L, pos)

  if i == len(L):

    if direction == 1:

      return INF

    elif direction == -1:

      res = abs(L[i-1]-pos)

      next_pos = L[i-1]

  elif L[i] == pos:

    res = 0

    next_pos = pos

  else:

    if direction == 1:

      res = abs(L[i]-pos)

      next_pos = L[i]

    elif direction == -1:

      if i == 0:

        return INF



      res = abs(L[i-1]-pos)

      next_pos = L[i-1]



  if count == 1:

    return res



  res0 = res + dfs(direction, tors*(-1), next_pos, count-1)

  res1 = res + dfs(direction*(-1), tors*(-1), next_pos, count-1)



  return min(res0, res1)



for x in X:

  res0 = dfs(1, 1, x, 2)

  res1 = dfs(-1, 1, x, 2)

  res2 = dfs(1, -1, x, 2)

  res3 = dfs(-1, -1, x, 2)



  print((min(res0, res1, res2, res3)))
import bisect

A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
    x = int(eval(input()))
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[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

a, b, q = list(map(int, sys.stdin.readline().split()))
S = []
for _ in range(a):
    S.append(int(sys.stdin.readline()))
T = []
for _ in range(b):
    T.append(int(sys.stdin.readline()))
X = []
for _ in range(q):
    X.append(int(sys.stdin.readline()))
INF = 10**11


def dfs(direction, tors, pos, count):
    if tors == 1:
        L = T
    elif tors == -1:
        L = S
    i = bisect_left(L, pos)
    if i == len(L):
        if direction == 1:
            return INF
        elif direction == -1:
            res = abs(L[i - 1] - pos)
            next_pos = L[i - 1]
    elif L[i] == pos:
        res = 0
        next_pos = pos
    else:
        if direction == 1:
            res = abs(L[i] - pos)
            next_pos = L[i]
        elif direction == -1:
            if i == 0:
                return INF
            res = abs(L[i - 1] - pos)
            next_pos = L[i - 1]
    if count == 1:
        return res
    res0 = res + dfs(direction, tors * (-1), next_pos, count - 1)
    res1 = res + dfs(direction * (-1), tors * (-1), next_pos, count - 1)
    return min(res0, res1)


for x in X:
    res0 = dfs(1, 1, x, 2)
    res1 = dfs(-1, 1, x, 2)
    res2 = dfs(1, -1, x, 2)
    res3 = dfs(-1, -1, x, 2)
    print((min(res0, res1, res2, res3)))

-import bisect +import sys +from bisect import bisect_left -A, B, Q = list(map(int, input().split())) -INF = 10**18 -s = [-INF] + [int(eval(input())) for i in range(A)] + [INF] -t = [-INF] + [int(eval(input())) for i in range(B)] + [INF] -for q in range(Q): -    x = int(eval(input())) -    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x) -    res = INF -    for S in [s[b - 1], s[b]]: -        for T in [t[d - 1], t[d]]: -            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T) -            res = min(res, d1, d2) -    print(res) +a, b, q = list(map(int, sys.stdin.readline().split())) +S = [] +for _ in range(a): +    S.append(int(sys.stdin.readline())) +T = [] +for _ in range(b): +    T.append(int(sys.stdin.readline())) +X = [] +for _ in range(q): +    X.append(int(sys.stdin.readline())) +INF = 10**11 + + +def dfs(direction, tors, pos, count): +    if tors == 1: +        L = T +    elif tors == -1: +        L = S +    i = bisect_left(L, pos) +    if i == len(L): +        if direction == 1: +            return INF +        elif direction == -1: +            res = abs(L[i - 1] - pos) +            next_pos = L[i - 1] +    elif L[i] == pos: +        res = 0 +        next_pos = pos +    else: +        if direction == 1: +            res = abs(L[i] - pos) +            next_pos = L[i] +        elif direction == -1: +            if i == 0: +                return INF +            res = abs(L[i - 1] - pos) +            next_pos = L[i - 1] +    if count == 1: +        return res +    res0 = res + dfs(direction, tors * (-1), next_pos, count - 1) +    res1 = res + dfs(direction * (-1), tors * (-1), next_pos, count - 1) +    return min(res0, res1) + + +for x in X: +    res0 = dfs(1, 1, x, 2) +    res1 = dfs(-1, 1, x, 2) +    res2 = dfs(1, -1, x, 2) +    res3 = dfs(-1, -1, x, 2) +    print((min(res0, res1, res2, res3)))