#!/usr/bin/python
# coding: utf-8
import os
from sys import stdin, stdout

if(os.getenv('__LOCAL__')):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    __input_path = os.path.join(__dirname, __inputname)
    __output_path = os.path.join(__dirname, __outputname)
    stdin = open(__input_path)
    # stdout = open(__output_path, "w")

def main():
    A, B, Q = map(int, stdin.readline().rstrip().split(' '))
    s = list()
    t = list()
    s.append(-1e12)
    t.append(-1e12)
    s += [int(stdin.readline()) for _ in range(A)]
    t += [int(stdin.readline()) for _ in range(B)]
    X = [int(stdin.readline()) for _ in range(Q)]
    ansvec = list()
    s.append(1e12)
    t.append(1e12)
    # stdout.write("{}\n".format(s))
    # stdout.write("{}\n".format(t))
    # stdout.write("{}\n".format(X))
    for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

    for a in ansvec:
        stdout.write("{}\n".format(a))

if __name__ == "__main__":
    main() import os os from sys import stdin, stdout if(os.getenv('__LOCAL__')):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    __input_path = os.path.join(__dirname, __inputname)
    __output_path = os.path.join(__dirname, __outputname)
    stdin = open(__input_path)
    # stdout = open(__output_path, "w") os.getenv('__LOCAL__') os.getenv os getenv '__LOCAL__' __dirname = os.path.dirname(__file__) __dirname os.path.dirname(__file__) os.path.dirname os.path os path dirname __file__ __basename = os.path.splitext(os.path.basename(__file__))[0] __basename os.path.splitext(os.path.basename(__file__))[0] os.path.splitext(os.path.basename(__file__)) os.path.splitext os.path os path splitext os.path.basename(__file__) os.path.basename os.path os path basename __file__ 0 __inputname = './input/' + __basename + '.txt' __inputname './input/' + __basename + '.txt' './input/' + __basename './input/' __basename '.txt' __outputname = './output/' + __basename + '.txt' __outputname './output/' + __basename + '.txt' './output/' + __basename './output/' __basename '.txt' __input_path = os.path.join(__dirname, __inputname) __input_path os.path.join(__dirname, __inputname) os.path.join os.path os path join __dirname __inputname __output_path = os.path.join(__dirname, __outputname) __output_path os.path.join(__dirname, __outputname) os.path.join os.path os path join __dirname __outputname stdin = open(__input_path) stdin open(__input_path) open __input_path def main():
    A, B, Q = map(int, stdin.readline().rstrip().split(' '))
    s = list()
    t = list()
    s.append(-1e12)
    t.append(-1e12)
    s += [int(stdin.readline()) for _ in range(A)]
    t += [int(stdin.readline()) for _ in range(B)]
    X = [int(stdin.readline()) for _ in range(Q)]
    ansvec = list()
    s.append(1e12)
    t.append(1e12)
    # stdout.write("{}\n".format(s))
    # stdout.write("{}\n".format(t))
    # stdout.write("{}\n".format(X))
    for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

    for a in ansvec:
        stdout.write("{}\n".format(a)) main A, B, Q = map(int, stdin.readline().rstrip().split(' ')) A map(int, stdin.readline().rstrip().split(' ')) map int stdin.readline().rstrip().split(' ') stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split ' ' B Q s = list() s list() list t = list() t list() list s.append(-1e12) s.append s append -1e12 t.append(-1e12) t.append t append -1e12 int(stdin.readline()) for _ in range(A) for _ in range(A) _ range(A) range A for _ in range(A) int(stdin.readline()) int stdin.readline() stdin.readline stdin readline s += [int(stdin.readline()) for _ in range(A)] s [int(stdin.readline()) for _ in range(A)] int(stdin.readline()) for _ in range(B) for _ in range(B) _ range(B) range B for _ in range(B) int(stdin.readline()) int stdin.readline() stdin.readline stdin readline t += [int(stdin.readline()) for _ in range(B)] t [int(stdin.readline()) for _ in range(B)] int(stdin.readline()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(stdin.readline()) int stdin.readline() stdin.readline stdin readline X = [int(stdin.readline()) for _ in range(Q)] X [int(stdin.readline()) for _ in range(Q)] ansvec = list() ansvec list() list s.append(1e12) s.append s append 1e12 t.append(1e12) t.append t append 1e12 for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

     x X ls = 0 ls 0 rs = A+2 rs A+2 A 2 lt = 0 lt 0 rt = B+2 rt B+2 B 2 while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

         rs-ls>1 rs-ls rs ls 1 mids=(ls+rs)//2 mids (ls+rs)//2 ls+rs ls rs 2 if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

         s[mids]<=x s[mids] s mids x ls = mids ls mids rs = mids rs mids while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

         rt-lt>1 rt-lt rt lt 1 midt=(lt+rt)//2 midt (lt+rt)//2 lt+rt lt rt 2 if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

         t[midt]<=x t[midt] t midt x lt = midt lt midt rt = midt rt midt if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
         t[lt]<=s[ls] and s[rs]<=t[rt] t[lt]<=s[ls] t[lt] t lt s[ls] s ls s[rs]<=t[rt] s[rs] s rs t[rt] t rt ans = min(abs(t[lt]-x),abs(t[rt]-x)) ans min(abs(t[lt]-x),abs(t[rt]-x)) min abs(t[lt]-x) abs t[lt]-x t[lt] t lt x abs(t[rt]-x) abs t[rt]-x t[rt] t rt x elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
         s[ls]<=t[lt] and t[rt]<=s[rs] s[ls]<=t[lt] s[ls] s ls t[lt] t lt t[rt]<=s[rs] t[rt] t rt s[rs] s rs ans = min(abs(s[ls]-x),abs(s[rs]-x)) ans min(abs(s[ls]-x),abs(s[rs]-x)) min abs(s[ls]-x) abs s[ls]-x s[ls] s ls x abs(s[rs]-x) abs s[rs]-x s[rs] s rs x elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
         s[ls]<=t[lt] and s[rs]<=t[rt] s[ls]<=t[lt] s[ls] s ls t[lt] t lt s[rs]<=t[rt] s[rs] s rs t[rt] t rt ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x)) ans min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x)) min abs(s[ls]-x) abs s[ls]-x s[ls] s ls x abs(t[rt]-x) abs t[rt]-x t[rt] t rt x 2*abs(s[rs]-x)+abs(t[lt]-x) 2*abs(s[rs]-x) 2 abs(s[rs]-x) abs s[rs]-x s[rs] s rs x abs(t[lt]-x) abs t[lt]-x t[lt] t lt x 2*abs(t[lt]-x)+abs(s[rs]-x) 2*abs(t[lt]-x) 2 abs(t[lt]-x) abs t[lt]-x t[lt] t lt x abs(s[rs]-x) abs s[rs]-x s[rs] s rs x elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
         t[lt]<=s[ls] and t[rt]<=s[rs] t[lt]<=s[ls] t[lt] t lt s[ls] s ls t[rt]<=s[rs] t[rt] t rt s[rs] s rs ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x)) ans min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x)) min abs(t[lt]-x) abs t[lt]-x t[lt] t lt x abs(s[rs]-x) abs s[rs]-x s[rs] s rs x 2*abs(s[ls]-x)+abs(t[rt]-x) 2*abs(s[ls]-x) 2 abs(s[ls]-x) abs s[ls]-x s[ls] s ls x abs(t[rt]-x) abs t[rt]-x t[rt] t rt x 2*abs(t[rt]-x)+abs(s[ls]-x) 2*abs(t[rt]-x) 2 abs(t[rt]-x) abs t[rt]-x t[rt] t rt x abs(s[ls]-x) abs s[ls]-x s[ls] s ls x ansvec.append(ans) ansvec.append ansvec append ans for a in ansvec:
        stdout.write("{}\n".format(a)) a ansvec stdout.write("{}\n".format(a)) stdout.write stdout write "{}\n".format(a) "{}\n".format "{}\n" format a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    A, B, Q = map(int, stdin.readline().rstrip().split(' '))
    s = list()
    t = list()
    s.append(-1e12)
    t.append(-1e12)
    s += [int(stdin.readline()) for _ in range(A)]
    t += [int(stdin.readline()) for _ in range(B)]
    X = [int(stdin.readline()) for _ in range(Q)]
    ansvec = list()
    s.append(1e12)
    t.append(1e12)
    # stdout.write("{}\n".format(s))
    # stdout.write("{}\n".format(t))
    # stdout.write("{}\n".format(X))
    for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

    for a in ansvec:
        stdout.write("{}\n".format(a)) def main():
    A, B, Q = map(int, stdin.readline().rstrip().split(' '))
    s = list()
    t = list()
    s.append(-1e12)
    t.append(-1e12)
    s += [int(stdin.readline()) for _ in range(A)]
    t += [int(stdin.readline()) for _ in range(B)]
    X = [int(stdin.readline()) for _ in range(Q)]
    ansvec = list()
    s.append(1e12)
    t.append(1e12)
    # stdout.write("{}\n".format(s))
    # stdout.write("{}\n".format(t))
    # stdout.write("{}\n".format(X))
    for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

    for a in ansvec:
        stdout.write("{}\n".format(a)) main stdin = open(__input_path) open(__input_path) stdin
#!/usr/bin/python
# coding: utf-8
import os
from sys import stdin, stdout

if(os.getenv('__LOCAL__')):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    __input_path = os.path.join(__dirname, __inputname)
    __output_path = os.path.join(__dirname, __outputname)
    stdin = open(__input_path)
    # stdout = open(__output_path, "w")

def main():
    A, B, Q = map(int, stdin.readline().rstrip().split(' '))
    s = list()
    t = list()
    s.append(-1e12)
    t.append(-1e12)
    s += [int(stdin.readline()) for _ in range(A)]
    t += [int(stdin.readline()) for _ in range(B)]
    X = [int(stdin.readline()) for _ in range(Q)]
    ansvec = list()
    s.append(1e12)
    t.append(1e12)
    # stdout.write("{}\n".format(s))
    # stdout.write("{}\n".format(t))
    # stdout.write("{}\n".format(X))
    for x in X:
        ls = 0
        rs = A+2
        lt = 0
        rt = B+2
        while(rs-ls>1):
            mids=(ls+rs)//2
            if(s[mids]<=x):
                ls = mids
            else:
                rs = mids

        while(rt-lt>1):
            midt=(lt+rt)//2
            if(t[midt]<=x):
                lt = midt
            else:
                rt = midt

        if(t[lt]<=s[ls] and s[rs]<=t[rt]):
            ans = min(abs(t[lt]-x),abs(t[rt]-x))
        elif(s[ls]<=t[lt] and t[rt]<=s[rs]):
            ans = min(abs(s[ls]-x),abs(s[rs]-x))
        elif(s[ls]<=t[lt] and s[rs]<=t[rt]):
            ans = min(abs(s[ls]-x),abs(t[rt]-x), 2*abs(s[rs]-x)+abs(t[lt]-x), 2*abs(t[lt]-x)+abs(s[rs]-x))
        elif(t[lt]<=s[ls] and t[rt]<=s[rs]):
            ans = min(abs(t[lt]-x),abs(s[rs]-x), 2*abs(s[ls]-x)+abs(t[rt]-x), 2*abs(t[rt]-x)+abs(s[ls]-x))
        ansvec.append(ans)

    for a in ansvec:
        stdout.write("{}\n".format(a))

if __name__ == "__main__":
    main()