import bisect
import itertools
import sys

def main(args):
    
    A, B, Q = map(int,input().split())
    S = [0]*A
    T = [0]*B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    S = [-10**18] + S + [10**18]
    T = [-10**18] + T +[10**18]
    
    def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
    for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        print(ans)
        
if __name__ == '__main__':
    main(sys.argv[1:]) import bisect bisect import itertools itertools import sys sys def main(args):
    
    A, B, Q = map(int,input().split())
    S = [0]*A
    T = [0]*B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    S = [-10**18] + S + [10**18]
    T = [-10**18] + T +[10**18]
    
    def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
    for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        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 = [0]*A S [0]*A [0] 0 A T = [0]*B T [0]*B [0] 0 B for i in range(A):
        S[i] = int(input())
     i range(A) range A S[i] = int(input()) S[i] S i int(input()) int input() input for i in range(B):
        T[i] = int(input())
    
     i range(B) range B T[i] = int(input()) T[i] T i int(input()) int input() input S = [-10**18] + S + [10**18] S [-10**18] + S + [10**18] [-10**18] + S [-10**18] -10**18 -10 18 S [10**18] 10**18 10 18 T = [-10**18] + T +[10**18] T [-10**18] + T +[10**18] [-10**18] + T [-10**18] -10**18 -10 18 T [10**18] 10**18 10 18 def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
     solve jinja_l = S[j-1] jinja_l S[j-1] S j-1 j 1 jinja_r = S[j] jinja_r S[j] S j tera_l = T[t-1] tera_l T[t-1] T t-1 t 1 tera_r = T[t] tera_r T[t] T t jinja = [jinja_l, jinja_r] jinja [jinja_l, jinja_r] jinja_l jinja_r tera = [tera_l ,tera_r] tera [tera_l ,tera_r] tera_l tera_r ans = float('inf') ans float('inf') float 'inf' for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
         u v list(itertools.product(jinja, tera)) list itertools.product(jinja, tera) itertools.product itertools product jinja tera ans = min(ans, abs(start-u)+abs(v-u)) ans min(ans, abs(start-u)+abs(v-u)) min ans abs(start-u)+abs(v-u) abs(start-u) abs start-u start u abs(v-u) abs v-u v u ans = min(ans, abs(v-start)+abs(v-u)) ans min(ans, abs(v-start)+abs(v-u)) min ans abs(v-start)+abs(v-u) abs(v-start) abs v-start v start abs(v-u) abs v-u v u return ans ans j j t t start start for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        print(ans)
         i range(Q) range Q x = int(input()) x int(input()) int input() input ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x) ans solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x) solve bisect.bisect_left(S, x) bisect.bisect_left bisect bisect_left S x bisect.bisect_left(T ,x) bisect.bisect_left bisect bisect_left T x x print(ans) print ans args args if __name__ == '__main__':
    main(sys.argv[1:]) __name__ == '__main__' __name__ '__main__' main(sys.argv[1:]) main sys.argv[1:] sys.argv sys argv 1: 1 def main(args):
    
    A, B, Q = map(int,input().split())
    S = [0]*A
    T = [0]*B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    S = [-10**18] + S + [10**18]
    T = [-10**18] + T +[10**18]
    
    def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
    for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        print(ans)
         def main(args):
    
    A, B, Q = map(int,input().split())
    S = [0]*A
    T = [0]*B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    S = [-10**18] + S + [10**18]
    T = [-10**18] + T +[10**18]
    
    def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
    for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        print(ans)
         main
import bisect
import itertools
import sys

def main(args):
    
    A, B, Q = map(int,input().split())
    S = [0]*A
    T = [0]*B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    S = [-10**18] + S + [10**18]
    T = [-10**18] + T +[10**18]
    
    def solve(j, t, start):
        jinja_l = S[j-1]
        jinja_r = S[j]
        tera_l = T[t-1]
        tera_r = T[t]
        jinja = [jinja_l, jinja_r]
        tera = [tera_l ,tera_r]
        
        ans = float('inf')
        for u,v in list(itertools.product(jinja, tera)):
            ans = min(ans, abs(start-u)+abs(v-u))
            ans = min(ans, abs(v-start)+abs(v-u))
        
        return ans
    
    for i in range(Q):
        x = int(input())
        ans = solve(bisect.bisect_left(S, x), bisect.bisect_left(T ,x), x)
        print(ans)
        
if __name__ == '__main__':
    main(sys.argv[1:])