import sys
input = sys.stdin.readline


def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high


def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low


A, B, Q = map(int, input().split(' '))
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())
    shr_u, shr_l = upper(s, x), lower(s, x)
    tmp_u, tmp_l = upper(t, x), lower(t, x)
    ans = 10 ** 18
    if shr_u != A and tmp_u != B:
        ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x))
    if shr_l != -1 and tmp_l != -1:
        ans = min(ans, max(x - s[shr_l], x - t[tmp_l]))
    if shr_l != -1 and tmp_u != B:
        cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x)
        ans = min(ans, cost)
    if shr_u != A and tmp_l != -1:
        cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l])
        ans = min(ans, cost)
    print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high upper if arr[0] > x:
        return 0
     arr[0] > x arr[0] arr 0 x return 0 0 high, low = len(arr), 0 high len(arr) len arr low 0 while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
     high - low > 1 high - low high low 1 mid = (high + low) // 2 mid (high + low) // 2 high + low high low 2 if arr[mid] > x:
            high = mid
        else:
            low = mid
     arr[mid] > x arr[mid] arr mid x high = mid high mid low = mid low mid return high high arr arr x x def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low lower if arr[-1] < x:
        return len(arr) - 1
     arr[-1] < x arr[-1] arr -1 x return len(arr) - 1 len(arr) - 1 len(arr) len arr 1 high, low = len(arr) - 1, -1 high len(arr) - 1 len(arr) len arr 1 low -1 while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
     high - low > 1 high - low high low 1 mid = (high + low) // 2 mid (high + low) // 2 high + low high low 2 if arr[mid] < x:
            low = mid
        else:
            high = mid
     arr[mid] < x arr[mid] arr mid x low = mid low mid high = mid high mid return low low arr arr x x A, B, Q = map(int, input().split(' ')) A map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' B Q int(input()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(input()) int input() input s = [int(input()) for _ in range(A)] s [int(input()) for _ in range(A)] int(input()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(input()) int input() input t = [int(input()) for _ in range(B)] t [int(input()) for _ in range(B)] for _ in range(Q):
    x = int(input())
    shr_u, shr_l = upper(s, x), lower(s, x)
    tmp_u, tmp_l = upper(t, x), lower(t, x)
    ans = 10 ** 18
    if shr_u != A and tmp_u != B:
        ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x))
    if shr_l != -1 and tmp_l != -1:
        ans = min(ans, max(x - s[shr_l], x - t[tmp_l]))
    if shr_l != -1 and tmp_u != B:
        cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x)
        ans = min(ans, cost)
    if shr_u != A and tmp_l != -1:
        cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l])
        ans = min(ans, cost)
    print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input shr_u, shr_l = upper(s, x), lower(s, x) shr_u upper(s, x) upper s x shr_l lower(s, x) lower s x tmp_u, tmp_l = upper(t, x), lower(t, x) tmp_u upper(t, x) upper t x tmp_l lower(t, x) lower t x ans = 10 ** 18 ans 10 ** 18 10 18 if shr_u != A and tmp_u != B:
        ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x))
     shr_u != A and tmp_u != B shr_u != A shr_u A tmp_u != B tmp_u B ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x)) ans min(ans, max(s[shr_u] - x, t[tmp_u] - x)) min ans max(s[shr_u] - x, t[tmp_u] - x) max s[shr_u] - x s[shr_u] s shr_u x t[tmp_u] - x t[tmp_u] t tmp_u x if shr_l != -1 and tmp_l != -1:
        ans = min(ans, max(x - s[shr_l], x - t[tmp_l]))
     shr_l != -1 and tmp_l != -1 shr_l != -1 shr_l -1 tmp_l != -1 tmp_l -1 ans = min(ans, max(x - s[shr_l], x - t[tmp_l])) ans min(ans, max(x - s[shr_l], x - t[tmp_l])) min ans max(x - s[shr_l], x - t[tmp_l]) max x - s[shr_l] x s[shr_l] s shr_l x - t[tmp_l] x t[tmp_l] t tmp_l if shr_l != -1 and tmp_u != B:
        cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x)
        ans = min(ans, cost)
     shr_l != -1 and tmp_u != B shr_l != -1 shr_l -1 tmp_u != B tmp_u B cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x) cost t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x) t[tmp_u] - s[shr_l] t[tmp_u] t tmp_u s[shr_l] s shr_l min(x - s[shr_l], t[tmp_u] - x) min x - s[shr_l] x s[shr_l] s shr_l t[tmp_u] - x t[tmp_u] t tmp_u x ans = min(ans, cost) ans min(ans, cost) min ans cost if shr_u != A and tmp_l != -1:
        cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l])
        ans = min(ans, cost)
     shr_u != A and tmp_l != -1 shr_u != A shr_u A tmp_l != -1 tmp_l -1 cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l]) cost s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l]) s[shr_u] - t[tmp_l] s[shr_u] s shr_u t[tmp_l] t tmp_l min(s[shr_u] - x, x - t[tmp_l]) min s[shr_u] - x s[shr_u] s shr_u x x - t[tmp_l] x t[tmp_l] t tmp_l ans = min(ans, cost) ans min(ans, cost) min ans cost print(ans) print ans tmp_u, tmp_l = upper(t, x), lower(t, x) upper(t, x) tmp_u shr_u, shr_l = upper(s, x), lower(s, x) upper(s, x) shr_u ans = min(ans, max(x - s[shr_l], x - t[tmp_l])) min(ans, max(x - s[shr_l], x - t[tmp_l])) ans x = int(input()) int(input()) x tmp_l = upper(t, x), lower(t, x) lower(t, x) tmp_l t = [int(input()) for _ in range(B)] [int(input()) for _ in range(B)] t cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l]) s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l]) cost B, Q = map(int, input().split(' ')) map(int, input().split(' ')) B s = [int(input()) for _ in range(A)] [int(input()) for _ in range(A)] s input = sys.stdin.readline sys.stdin.readline input Q = map(int, input().split(' ')) map(int, input().split(' ')) Q def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low lower ans = 10 ** 18 10 ** 18 ans def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high upper ans = min(ans, cost) min(ans, cost) ans shr_l = upper(s, x), lower(s, x) lower(s, x) shr_l A, B, Q = map(int, input().split(' ')) map(int, input().split(' ')) A ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x)) min(ans, max(s[shr_u] - x, t[tmp_u] - x)) ans ans = min(ans, cost) min(ans, cost) ans cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x) t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x) cost
import sys
input = sys.stdin.readline


def upper(arr, x):
    # xよりも大きい最小のindexを返す
    if arr[0] > x:
        return 0
    high, low = len(arr), 0
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] > x:
            high = mid
        else:
            low = mid
    return high


def lower(arr, x):
    # xよりも小さい最大のindexを返す
    if arr[-1] < x:
        return len(arr) - 1
    high, low = len(arr) - 1, -1
    while high - low > 1:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid
        else:
            high = mid
    return low


A, B, Q = map(int, input().split(' '))
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]

for _ in range(Q):
    x = int(input())
    shr_u, shr_l = upper(s, x), lower(s, x)
    tmp_u, tmp_l = upper(t, x), lower(t, x)
    ans = 10 ** 18
    if shr_u != A and tmp_u != B:
        ans = min(ans, max(s[shr_u] - x, t[tmp_u] - x))
    if shr_l != -1 and tmp_l != -1:
        ans = min(ans, max(x - s[shr_l], x - t[tmp_l]))
    if shr_l != -1 and tmp_u != B:
        cost = t[tmp_u] - s[shr_l] + min(x - s[shr_l], t[tmp_u] - x)
        ans = min(ans, cost)
    if shr_u != A and tmp_l != -1:
        cost = s[shr_u] - t[tmp_l] + min(s[shr_u] - x, x - t[tmp_l])
        ans = min(ans, cost)
    print(ans)