import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

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

def main():
    A, B, Q = map(int, input().split())
    s, t = [], []
    for _ in range(A):
        s.append(int(input()))
    for _ in range(B):
        t.append(int(input()))
    for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans)






main() import sys sys from bisect import * from heapq import * from collections import * from itertools import * from functools import * from math import * from fractions import * sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    A, B, Q = map(int, input().split())
    s, t = [], []
    for _ in range(A):
        s.append(int(input()))
    for _ in range(B):
        t.append(int(input()))
    for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans) main A, B, Q = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Q s, t = [], [] s [] t [] for _ in range(A):
        s.append(int(input()))
     _ range(A) range A s.append(int(input())) s.append s append int(input()) int input() input for _ in range(B):
        t.append(int(input()))
     _ range(B) range B t.append(int(input())) t.append t append int(input()) int input() input for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans) _ range(Q) range Q x = int(input()) x int(input()) int input() input i = bisect_left(s, x) i bisect_left(s, x) bisect_left s x j = bisect_left(t, x) j bisect_left(t, x) bisect_left t x s[k] for k in [i - 1, i] if 0 <= k < A for k in [i - 1, i] if 0 <= k < A k [i - 1, i] i - 1 i 1 i 0 <= k < A 0 <= k 0 k A if 0 <= k < A s[k] s k s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A] s_candidates [s[k] for k in [i - 1, i] if 0 <= k < A] t[k] for k in [j - 1, j] if 0 <= k < B for k in [j - 1, j] if 0 <= k < B k [j - 1, j] j - 1 j 1 j 0 <= k < B 0 <= k 0 k B if 0 <= k < B t[k] t k t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B] t_candidates [t[k] for k in [j - 1, j] if 0 <= k < B] ans = float('inf') ans float('inf') float 'inf' for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
         s_candidate s_candidates for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
         t_candidate t_candidates right = max(x, s_candidate, t_candidate) - x right max(x, s_candidate, t_candidate) - x max(x, s_candidate, t_candidate) max x s_candidate t_candidate x left = x - min(x, s_candidate, t_candidate) left x - min(x, s_candidate, t_candidate) x min(x, s_candidate, t_candidate) min x s_candidate t_candidate ans = min(ans, min(right, left) * 2 + max(right, left)) ans min(ans, min(right, left) * 2 + max(right, left)) min ans min(right, left) * 2 + max(right, left) min(right, left) * 2 min(right, left) min right left 2 max(right, left) max right left print(ans) print ans main() main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def main():
    A, B, Q = map(int, input().split())
    s, t = [], []
    for _ in range(A):
        s.append(int(input()))
    for _ in range(B):
        t.append(int(input()))
    for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans) def main():
    A, B, Q = map(int, input().split())
    s, t = [], []
    for _ in range(A):
        s.append(int(input()))
    for _ in range(B):
        t.append(int(input()))
    for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans) main
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

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

def main():
    A, B, Q = map(int, input().split())
    s, t = [], []
    for _ in range(A):
        s.append(int(input()))
    for _ in range(B):
        t.append(int(input()))
    for _ in range(Q):
        x = int(input())
        i = bisect_left(s, x)
        j = bisect_left(t, x)
        # visit s[i - 1] or s[i]
        # visit t[j - 1] or t[j]
        s_candidates = [s[k] for k in [i - 1, i] if 0 <= k < A]
        t_candidates = [t[k] for k in [j - 1, j] if 0 <= k < B]
        ans = float('inf')
        for s_candidate in s_candidates:
            for t_candidate in t_candidates:
                right = max(x, s_candidate, t_candidate) - x
                left = x - min(x, s_candidate, t_candidate)
                ans = min(ans, min(right, left) * 2 + max(right, left))
        print(ans)






main()
