function parse_table(N)
    local tbl = {}
    for i=1,N do
        table.insert(tbl, io.read("n"))
    end
    return tbl
end

function find_leftmost_ge(a, x)
    local i, j = 1, #a + 1
    while i < j do
        m = (i + j) // 2
        if a[m] < x then
            i = m + 1
        else
            j = m
        end
    end
    return i
end

function main()
    local A, B, Q = io.read("n", "n", "n")
    local S = parse_table(A)
    local T = parse_table(B)
    local function search(x, sl_i, tl_i)
        local cur_min = 100000000000
        for _, si in ipairs({sl_i - 1, sl_i}) do
            for _, ti in ipairs({tl_i - 1, tl_i}) do
                if si >= 1 and si <= #S
                    and ti >= 1 and ti <= #T then
                    local sv = S[si]
                    local tv = T[ti]
                    local d = math.abs(tv - sv) + math.min(math.abs(sv - x), math.abs(tv - x))
                    cur_min = math.min(cur_min, d)
                end
            end
        end
        return cur_min
    end
    for i=1,Q do
        x = io.read("n")
        local sl_i = find_leftmost_ge(S, x)
        local tl_i = find_leftmost_ge(T, x)
        print(search(x, sl_i, tl_i))
    end
end

main()
