import bisect



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



shrines = []

for i in range(A):

    shrines.append(int(eval(input())))



temples = []

for i in range(B):

    temples.append(int(eval(input())))



shortest_s_to_t = {}

for shrine in shrines:

    index = bisect.bisect_left(temples, shrine)

    if index == 0:

        distance = abs(shrine - temples[index])

        shortest_s_to_t[shrine] = distance

    elif index == B:

        distance = abs(shrine - temples[index - 1])

        shortest_s_to_t[shrine] = distance

    else:

        distance_left = abs(shrine - temples[index - 1])

        distance_right = abs(shrine - temples[index])

        shortest_s_to_t[shrine] = min(distance_left, distance_right)



shortest_t_to_s = {}

for temple in temples:

    index = bisect.bisect_left(shrines, temple)

    if index == 0:

        distance = abs(temple - shrines[index])

        shortest_t_to_s[temple] = distance

    elif index == A:

        distance = abs(temple - shrines[index - 1])

        shortest_t_to_s[temple] = distance

    else:

        distance_left = abs(temple - shrines[index - 1])

        distance_right = abs(temple - shrines[index])

        shortest_t_to_s[temple] = min(distance_left, distance_right)



for i in range(Q):

    x = int(eval(input()))



    # shrine to temple

    index = bisect.bisect_left(shrines, x)

    ans = 10**11

    if index > 0:

        left_shrine = shrines[index - 1]

        candidate = abs(x - left_shrine) + shortest_s_to_t[left_shrine]

        ans = min(ans, candidate)

    if index < A:

        right_shrine = shrines[index]

        candidate = abs(x - right_shrine) + shortest_s_to_t[right_shrine]

        ans = min(ans, candidate)



    # temple to shrine

    index = bisect.bisect_left(temples, x)

    if index > 0:

        left_temple = temples[index - 1]

        candidate = abs(x - left_temple) + shortest_t_to_s[left_temple]

        ans = min(ans, candidate)

    if index < B:

        right_temple = temples[index]

        candidate = abs(x - right_temple) + shortest_t_to_s[right_temple]

        ans = min(ans, candidate)



    print(ans)
import bisect

import sys



def input():

    return sys.stdin.readline()



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



shrines = []

for i in range(A):

    shrines.append(int(eval(input())))



temples = []

for i in range(B):

    temples.append(int(eval(input())))



shortest_s_to_t = {}

for shrine in shrines:

    index = bisect.bisect_left(temples, shrine)

    if index == 0:

        distance = abs(shrine - temples[index])

        shortest_s_to_t[shrine] = distance

    elif index == B:

        distance = abs(shrine - temples[index - 1])

        shortest_s_to_t[shrine] = distance

    else:

        distance_left = abs(shrine - temples[index - 1])

        distance_right = abs(shrine - temples[index])

        shortest_s_to_t[shrine] = min(distance_left, distance_right)



shortest_t_to_s = {}

for temple in temples:

    index = bisect.bisect_left(shrines, temple)

    if index == 0:

        distance = abs(temple - shrines[index])

        shortest_t_to_s[temple] = distance

    elif index == A:

        distance = abs(temple - shrines[index - 1])

        shortest_t_to_s[temple] = distance

    else:

        distance_left = abs(temple - shrines[index - 1])

        distance_right = abs(temple - shrines[index])

        shortest_t_to_s[temple] = min(distance_left, distance_right)



for i in range(Q):

    x = int(eval(input()))



    # shrine to temple

    index = bisect.bisect_left(shrines, x)

    ans = 10**11

    if index > 0:

        left_shrine = shrines[index - 1]

        candidate = abs(x - left_shrine) + shortest_s_to_t[left_shrine]

        ans = min(ans, candidate)

    if index < A:

        right_shrine = shrines[index]

        candidate = abs(x - right_shrine) + shortest_s_to_t[right_shrine]

        ans = min(ans, candidate)



    # temple to shrine

    index = bisect.bisect_left(temples, x)

    if index > 0:

        left_temple = temples[index - 1]

        candidate = abs(x - left_temple) + shortest_t_to_s[left_temple]

        ans = min(ans, candidate)

    if index < B:

        right_temple = temples[index]

        candidate = abs(x - right_temple) + shortest_t_to_s[right_temple]

        ans = min(ans, candidate)



    print(ans)
import bisect

A, B, Q = list(map(int, input().split()))
shrines = []
for i in range(A):
    shrines.append(int(eval(input())))
temples = []
for i in range(B):
    temples.append(int(eval(input())))
shortest_s_to_t = {}
for shrine in shrines:
    index = bisect.bisect_left(temples, shrine)
    if index == 0:
        distance = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = distance
    elif index == B:
        distance = abs(shrine - temples[index - 1])
        shortest_s_to_t[shrine] = distance
    else:
        distance_left = abs(shrine - temples[index - 1])
        distance_right = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = min(distance_left, distance_right)
shortest_t_to_s = {}
for temple in temples:
    index = bisect.bisect_left(shrines, temple)
    if index == 0:
        distance = abs(temple - shrines[index])
        shortest_t_to_s[temple] = distance
    elif index == A:
        distance = abs(temple - shrines[index - 1])
        shortest_t_to_s[temple] = distance
    else:
        distance_left = abs(temple - shrines[index - 1])
        distance_right = abs(temple - shrines[index])
        shortest_t_to_s[temple] = min(distance_left, distance_right)
for i in range(Q):
    x = int(eval(input()))
    # shrine to temple
    index = bisect.bisect_left(shrines, x)
    ans = 10**11
    if index > 0:
        left_shrine = shrines[index - 1]
        candidate = abs(x - left_shrine) + shortest_s_to_t[left_shrine]
        ans = min(ans, candidate)
    if index < A:
        right_shrine = shrines[index]
        candidate = abs(x - right_shrine) + shortest_s_to_t[right_shrine]
        ans = min(ans, candidate)
    # temple to shrine
    index = bisect.bisect_left(temples, x)
    if index > 0:
        left_temple = temples[index - 1]
        candidate = abs(x - left_temple) + shortest_t_to_s[left_temple]
        ans = min(ans, candidate)
    if index < B:
        right_temple = temples[index]
        candidate = abs(x - right_temple) + shortest_t_to_s[right_temple]
        ans = min(ans, candidate)
    print(ans)

import bisect
import sys


def input():
    return sys.stdin.readline()


A, B, Q = list(map(int, input().split()))
shrines = []
for i in range(A):
    shrines.append(int(eval(input())))
temples = []
for i in range(B):
    temples.append(int(eval(input())))
shortest_s_to_t = {}
for shrine in shrines:
    index = bisect.bisect_left(temples, shrine)
    if index == 0:
        distance = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = distance
    elif index == B:
        distance = abs(shrine - temples[index - 1])
        shortest_s_to_t[shrine] = distance
    else:
        distance_left = abs(shrine - temples[index - 1])
        distance_right = abs(shrine - temples[index])
        shortest_s_to_t[shrine] = min(distance_left, distance_right)
shortest_t_to_s = {}
for temple in temples:
    index = bisect.bisect_left(shrines, temple)
    if index == 0:
        distance = abs(temple - shrines[index])
        shortest_t_to_s[temple] = distance
    elif index == A:
        distance = abs(temple - shrines[index - 1])
        shortest_t_to_s[temple] = distance
    else:
        distance_left = abs(temple - shrines[index - 1])
        distance_right = abs(temple - shrines[index])
        shortest_t_to_s[temple] = min(distance_left, distance_right)
for i in range(Q):
    x = int(eval(input()))
    # shrine to temple
    index = bisect.bisect_left(shrines, x)
    ans = 10**11
    if index > 0:
        left_shrine = shrines[index - 1]
        candidate = abs(x - left_shrine) + shortest_s_to_t[left_shrine]
        ans = min(ans, candidate)
    if index < A:
        right_shrine = shrines[index]
        candidate = abs(x - right_shrine) + shortest_s_to_t[right_shrine]
        ans = min(ans, candidate)
    # temple to shrine
    index = bisect.bisect_left(temples, x)
    if index > 0:
        left_temple = temples[index - 1]
        candidate = abs(x - left_temple) + shortest_t_to_s[left_temple]
        ans = min(ans, candidate)
    if index < B:
        right_temple = temples[index]
        candidate = abs(x - right_temple) + shortest_t_to_s[right_temple]
        ans = min(ans, candidate)
    print(ans)

+import sys + + +def input(): +    return sys.stdin.readline() +