import bisect
a, b, q = map(int, input().split())
s = [int(input()) for _i in range(a)]
t = [int(input()) for _i in range(b)]
s.append(float('inf'))
s.insert(0, -float('inf'))
t.append(float('inf'))
t.insert(0, -float('inf'))
x = [int(input()) for _i in range(q)]

for i in x:
    n = bisect.bisect_right(s, i)
    m = bisect.bisect_right(t, i)
    print(min([abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-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 _i in range(a) for _i in range(a) _i range(a) range a for _i in range(a) int(input()) int input() input s = [int(input()) for _i in range(a)] s [int(input()) for _i in range(a)] int(input()) for _i in range(b) for _i in range(b) _i range(b) range b for _i in range(b) int(input()) int input() input t = [int(input()) for _i in range(b)] t [int(input()) for _i in range(b)] s.append(float('inf')) s.append s append float('inf') float 'inf' s.insert(0, -float('inf')) s.insert s insert 0 -float('inf') float('inf') float 'inf' t.append(float('inf')) t.append t append float('inf') float 'inf' t.insert(0, -float('inf')) t.insert t insert 0 -float('inf') float('inf') float 'inf' int(input()) for _i in range(q) for _i in range(q) _i range(q) range q for _i in range(q) int(input()) int input() input x = [int(input()) for _i in range(q)] x [int(input()) for _i in range(q)] for i in x:
    n = bisect.bisect_right(s, i)
    m = bisect.bisect_right(t, i)
    print(min([abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-1]))])) i x n = bisect.bisect_right(s, i) n bisect.bisect_right(s, i) bisect.bisect_right bisect bisect_right s i m = bisect.bisect_right(t, i) m bisect.bisect_right(t, i) bisect.bisect_right bisect bisect_right t i print(min([abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-1]))])) print min([abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-1]))]) min [abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-1]))] abs(max([s[n], t[m]])-i) abs max([s[n], t[m]])-i max([s[n], t[m]]) max [s[n], t[m]] s[n] s n t[m] t m i min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]) min([abs(i-s[n-1]), abs(i-t[m])]) min [abs(i-s[n-1]), abs(i-t[m])] abs(i-s[n-1]) abs i-s[n-1] i s[n-1] s n-1 n 1 abs(i-t[m]) abs i-t[m] i t[m] t m abs(s[n-1]-t[m]) abs s[n-1]-t[m] s[n-1] s n-1 n 1 t[m] t m min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]) min([abs(i-s[n]), abs(i-t[m-1])]) min [abs(i-s[n]), abs(i-t[m-1])] abs(i-s[n]) abs i-s[n] i s[n] s n abs(i-t[m-1]) abs i-t[m-1] i t[m-1] t m-1 m 1 abs(s[n]-t[m-1]) abs s[n]-t[m-1] s[n] s n t[m-1] t m-1 m 1 abs(i-min(s[n-1], t[m-1])) abs i-min(s[n-1], t[m-1]) i min(s[n-1], t[m-1]) min s[n-1] s n-1 n 1 t[m-1] t m-1 m 1 s = [int(input()) for _i in range(a)] [int(input()) for _i in range(a)] s m = bisect.bisect_right(t, i) bisect.bisect_right(t, i) m a, b, q = map(int, input().split()) map(int, input().split()) a x = [int(input()) for _i in range(q)] [int(input()) for _i in range(q)] x q = map(int, input().split()) map(int, input().split()) q b, q = map(int, input().split()) map(int, input().split()) b t = [int(input()) for _i in range(b)] [int(input()) for _i in range(b)] t n = bisect.bisect_right(s, i) bisect.bisect_right(s, i) n
import bisect
a, b, q = map(int, input().split())
s = [int(input()) for _i in range(a)]
t = [int(input()) for _i in range(b)]
s.append(float('inf'))
s.insert(0, -float('inf'))
t.append(float('inf'))
t.insert(0, -float('inf'))
x = [int(input()) for _i in range(q)]

for i in x:
    n = bisect.bisect_right(s, i)
    m = bisect.bisect_right(t, i)
    print(min([abs(max([s[n], t[m]])-i), min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m]), min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1]), abs(i-min(s[n-1], t[m-1]))]))