import bisect

import sys

def input_function():

    return sys.stdin.readline().rstrip()

input=input_function

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

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

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

for i in range(q):

    ans=999999999999

    x=int(eval(input()))

    w=bisect.bisect_left(s,x)

    for j in range(2):

        if not 0<=w-j<len(s):

            continue

        z=bisect.bisect_left(t,s[w-j])

        for k in range(2):

            if not 0<=z-k<len(t):

                continue

            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))

    w=bisect.bisect_left(t,x)

    for j in range(2):

        if not 0<=w-j<len(t):

            continue

        z=bisect.bisect_left(s,t[w-j])

        for k in range(2):

            if not 0<=z-k<len(s):

                continue

            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))

    print(ans)
import bisect

import sys

input=lambda : sys.stdin.readline().rstrip()

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

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

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

for i in range(q):

    ans=999999999999

    x=int(eval(input()))

    w=bisect.bisect_left(s,x)

    for j in range(2):

        if not 0<=w-j<len(s):

            continue

        z=bisect.bisect_left(t,s[w-j])

        for k in range(2):

            if not 0<=z-k<len(t):

                continue

            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))

    w=bisect.bisect_left(t,x)

    for j in range(2):

        if not 0<=w-j<len(t):

            continue

        z=bisect.bisect_left(s,t[w-j])

        for k in range(2):

            if not 0<=z-k<len(s):

                continue

            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))

    print(ans)
import bisect
import sys


def input_function():
    return sys.stdin.readline().rstrip()


input = input_function
a, b, q = list(map(int, input().split()))
s = sorted([int(eval(input())) for i in range(a)])
t = sorted([int(eval(input())) for i in range(b)])
for i in range(q):
    ans = 999999999999
    x = int(eval(input()))
    w = bisect.bisect_left(s, x)
    for j in range(2):
        if not 0 <= w - j < len(s):
            continue
        z = bisect.bisect_left(t, s[w - j])
        for k in range(2):
            if not 0 <= z - k < len(t):
                continue
            ans = min(ans, abs(x - s[w - j]) + abs(s[w - j] - t[z - k]))
    w = bisect.bisect_left(t, x)
    for j in range(2):
        if not 0 <= w - j < len(t):
            continue
        z = bisect.bisect_left(s, t[w - j])
        for k in range(2):
            if not 0 <= z - k < len(s):
                continue
            ans = min(ans, abs(x - t[w - j]) + abs(t[w - j] - s[z - k]))
    print(ans)

import bisect
import sys

input = lambda: sys.stdin.readline().rstrip()
a, b, q = list(map(int, input().split()))
s = sorted([int(eval(input())) for i in range(a)])
t = sorted([int(eval(input())) for i in range(b)])
for i in range(q):
    ans = 999999999999
    x = int(eval(input()))
    w = bisect.bisect_left(s, x)
    for j in range(2):
        if not 0 <= w - j < len(s):
            continue
        z = bisect.bisect_left(t, s[w - j])
        for k in range(2):
            if not 0 <= z - k < len(t):
                continue
            ans = min(ans, abs(x - s[w - j]) + abs(s[w - j] - t[z - k]))
    w = bisect.bisect_left(t, x)
    for j in range(2):
        if not 0 <= w - j < len(t):
            continue
        z = bisect.bisect_left(s, t[w - j])
        for k in range(2):
            if not 0 <= z - k < len(s):
                continue
            ans = min(ans, abs(x - t[w - j]) + abs(t[w - j] - s[z - k]))
    print(ans)

- -def input_function(): -    return sys.stdin.readline().rstrip() - - -input = input_function +input = lambda: sys.stdin.readline().rstrip()