import bisect



a, b, q =  [ int(v) for v in input().split() ]



temple_list = [ int(eval(input())) for i in range(a) ]

shrine_list = [ int(eval(input())) for i in range(b) ]





def excursion(x):

	global temple_list, shine_list

	temple_west = bisect.bisect_left(temple_list,x)

	shrine_west = bisect.bisect_left(shrine_list,x)



	tw, te, sw, se = temple_list[(temple_west-1)%a],temple_list[temple_west%a],shrine_list[(shrine_west-1)%b],shrine_list[(shrine_west)%b]

	print((min( abs(x-tw) + min(abs(sw-tw),abs(tw-se)) , abs(te-x) + min(abs(se-te),abs(te-sw)), abs(x-sw) + min(abs(tw-sw),abs(sw-te)) , abs(se-x) + min(abs(te-se),abs(se-tw)))))

	return 





for i in range(q):

	excursion(int(eval(input())))

import bisect

import sys

input = sys.stdin.readline



a, b, q =  [ int(v) for v in input().split() ]



temple_list = [ int(eval(input())) for i in range(a) ]

shrine_list = [ int(eval(input())) for i in range(b) ]





def excursion(x):

	global temple_list, shine_list

	temple_west = bisect.bisect_left(temple_list,x)

	shrine_west = bisect.bisect_left(shrine_list,x)



	tw, te, sw, se = temple_list[(temple_west-1)%a],temple_list[temple_west%a],shrine_list[(shrine_west-1)%b],shrine_list[(shrine_west)%b]

	print((min( abs(x-tw) + min(abs(sw-tw),abs(tw-se)) , abs(te-x) + min(abs(se-te),abs(te-sw)), abs(x-sw) + min(abs(tw-sw),abs(sw-te)) , abs(se-x) + min(abs(te-se),abs(se-tw)))))

	return 





for i in range(q):

	excursion(int(eval(input())))
import bisect

a, b, q = [int(v) for v in input().split()]
temple_list = [int(eval(input())) for i in range(a)]
shrine_list = [int(eval(input())) for i in range(b)]


def excursion(x):
    global temple_list, shine_list
    temple_west = bisect.bisect_left(temple_list, x)
    shrine_west = bisect.bisect_left(shrine_list, x)
    tw, te, sw, se = (
        temple_list[(temple_west - 1) % a],
        temple_list[temple_west % a],
        shrine_list[(shrine_west - 1) % b],
        shrine_list[(shrine_west) % b],
    )
    print(
        (
            min(
                abs(x - tw) + min(abs(sw - tw), abs(tw - se)),
                abs(te - x) + min(abs(se - te), abs(te - sw)),
                abs(x - sw) + min(abs(tw - sw), abs(sw - te)),
                abs(se - x) + min(abs(te - se), abs(se - tw)),
            )
        )
    )
    return


for i in range(q):
    excursion(int(eval(input())))

import bisect
import sys

input = sys.stdin.readline
a, b, q = [int(v) for v in input().split()]
temple_list = [int(eval(input())) for i in range(a)]
shrine_list = [int(eval(input())) for i in range(b)]


def excursion(x):
    global temple_list, shine_list
    temple_west = bisect.bisect_left(temple_list, x)
    shrine_west = bisect.bisect_left(shrine_list, x)
    tw, te, sw, se = (
        temple_list[(temple_west - 1) % a],
        temple_list[temple_west % a],
        shrine_list[(shrine_west - 1) % b],
        shrine_list[(shrine_west) % b],
    )
    print(
        (
            min(
                abs(x - tw) + min(abs(sw - tw), abs(tw - se)),
                abs(te - x) + min(abs(se - te), abs(te - sw)),
                abs(x - sw) + min(abs(tw - sw), abs(sw - te)),
                abs(se - x) + min(abs(te - se), abs(se - tw)),
            )
        )
    )
    return


for i in range(q):
    excursion(int(eval(input())))

+import sys +input = sys.stdin.readline