import bisect
A, B, Q = map(int,input().split())
s = [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20]
t = [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20]

for _ in range(Q):
    x = int(input())
    S = bisect.bisect_left(s,x)
    T = bisect.bisect_left(t,x)
    print(min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1])) import bisect bisect A, B, Q = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q int(input()) for k in range(A) for k in range(A) k range(A) range A for k in range(A) int(input()) int input() input s = [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20] s [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20] [-10**20] + [int(input()) for k in range(A)] [-10**20] -10**20 -10 20 [int(input()) for k in range(A)] [10**20,10**20] 10**20 10 20 10**20 10 20 int(input()) for k in range(B) for k in range(B) k range(B) range B for k in range(B) int(input()) int input() input t = [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20] t [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20] [-10**20] + [int(input()) for k in range(B)] [-10**20] -10**20 -10 20 [int(input()) for k in range(B)] [10**20,10**20] 10**20 10 20 10**20 10 20 for _ in range(Q):
    x = int(input())
    S = bisect.bisect_left(s,x)
    T = bisect.bisect_left(t,x)
    print(min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1])) _ range(Q) range Q x = int(input()) x int(input()) int input() input S = bisect.bisect_left(s,x) S bisect.bisect_left(s,x) bisect.bisect_left bisect bisect_left s x T = bisect.bisect_left(t,x) T bisect.bisect_left(t,x) bisect.bisect_left bisect bisect_left t x print(min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1])) print min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1]) min max(s[S],t[T])-x max(s[S],t[T]) max s[S] s S t[T] t T x x-min(s[S-1],t[T-1]) x min(s[S-1],t[T-1]) min s[S-1] s S-1 S 1 t[T-1] t T-1 T 1 s[S]-x + s[S]-t[T-1] s[S]-x + s[S] s[S]-x s[S] s S x s[S] s S t[T-1] t T-1 T 1 t[T]-x + t[T]-s[S-1] t[T]-x + t[T] t[T]-x t[T] t T x t[T] t T s[S-1] s S-1 S 1 x-s[S-1] + t[T]-s[S-1] x-s[S-1] + t[T] x-s[S-1] x s[S-1] s S-1 S 1 t[T] t T s[S-1] s S-1 S 1 x-t[T-1] + s[S]-t[T-1] x-t[T-1] + s[S] x-t[T-1] x t[T-1] t T-1 T 1 s[S] s S t[T-1] t T-1 T 1 B, Q = map(int,input().split()) map(int,input().split()) B s = [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20] [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20] s A, B, Q = map(int,input().split()) map(int,input().split()) A Q = map(int,input().split()) map(int,input().split()) Q S = bisect.bisect_left(s,x) bisect.bisect_left(s,x) S x = int(input()) int(input()) x t = [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20] [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20] t T = bisect.bisect_left(t,x) bisect.bisect_left(t,x) T
import bisect
A, B, Q = map(int,input().split())
s = [-10**20] + [int(input()) for k in range(A)] + [10**20,10**20]
t = [-10**20] + [int(input()) for k in range(B)] + [10**20,10**20]

for _ in range(Q):
    x = int(input())
    S = bisect.bisect_left(s,x)
    T = bisect.bisect_left(t,x)
    print(min(
        max(s[S],t[T])-x,
        x-min(s[S-1],t[T-1]),
        s[S]-x + s[S]-t[T-1],
        t[T]-x + t[T]-s[S-1],
        x-s[S-1] + t[T]-s[S-1],
        x-t[T-1] + s[S]-t[T-1]))
