from bisect import bisect_left

def main():

  a,b,q=list(map(int,input().split()))

  s=[int(eval(input())) for i in range(a)]

  t=[int(eval(input())) for i in range(b)]

  x=[int(eval(input())) for i in range(q)]

  inf=10**11

  minf=-10**11

  s=[minf]+s+[inf]

  t=[minf]+t+[inf]

  for i in range(q):

    ns=bisect_left(s,x[i])

    nt=bisect_left(t,x[i])

    ans=float('inf')

    for j in [s[ns],s[ns-1]]:

      for k in [t[nt],t[nt-1]]:

        ans=min(ans,min(abs(x[i]-j),abs(x[i]-k))+abs(max(j,k)-min(j,k)))

    print(ans)

if __name__=='__main__':

  main()
from bisect import bisect_left

import sys

def main():

  input=sys.stdin.readline

  a,b,q=list(map(int,input().split()))

  s=[int(eval(input())) for i in range(a)]

  t=[int(eval(input())) for i in range(b)]

  x=[int(eval(input())) for i in range(q)]

  inf=10**11

  minf=-10**11

  s=[minf]+s+[inf]

  t=[minf]+t+[inf]

  for i in range(q):

    ns=bisect_left(s,x[i])

    nt=bisect_left(t,x[i])

    ans=float('inf')

    for j in [s[ns],s[ns-1]]:

      for k in [t[nt],t[nt-1]]:

        ans=min(ans,min(abs(x[i]-j),abs(x[i]-k))+abs(max(j,k)-min(j,k)))

    print(ans)

if __name__=='__main__':

  main()
from bisect import bisect_left


def main():
    a, b, q = list(map(int, input().split()))
    s = [int(eval(input())) for i in range(a)]
    t = [int(eval(input())) for i in range(b)]
    x = [int(eval(input())) for i in range(q)]
    inf = 10**11
    minf = -(10**11)
    s = [minf] + s + [inf]
    t = [minf] + t + [inf]
    for i in range(q):
        ns = bisect_left(s, x[i])
        nt = bisect_left(t, x[i])
        ans = float("inf")
        for j in [s[ns], s[ns - 1]]:
            for k in [t[nt], t[nt - 1]]:
                ans = min(
                    ans, min(abs(x[i] - j), abs(x[i] - k)) + abs(max(j, k) - min(j, k))
                )
        print(ans)


if __name__ == "__main__":
    main()

from bisect import bisect_left
import sys


def main():
    input = sys.stdin.readline
    a, b, q = list(map(int, input().split()))
    s = [int(eval(input())) for i in range(a)]
    t = [int(eval(input())) for i in range(b)]
    x = [int(eval(input())) for i in range(q)]
    inf = 10**11
    minf = -(10**11)
    s = [minf] + s + [inf]
    t = [minf] + t + [inf]
    for i in range(q):
        ns = bisect_left(s, x[i])
        nt = bisect_left(t, x[i])
        ans = float("inf")
        for j in [s[ns], s[ns - 1]]:
            for k in [t[nt], t[nt - 1]]:
                ans = min(
                    ans, min(abs(x[i] - j), abs(x[i] - k)) + abs(max(j, k) - min(j, k))
                )
        print(ans)


if __name__ == "__main__":
    main()

+import sys +    input = sys.stdin.readline