(@a, @b, @q) = gets.chomp.split(' ').map(&:to_i)

@s = [0] * @a
@a.times { |i| @s[i] = gets.chomp.to_i }

@t = [0] * @b
@b.times { |i| @t[i] = gets.chomp.to_i }

def route1(x)
  d = 0
  
  i = @s.bsearch_index{|y| y >= x}
  if i == 0 then
    d = (x - @s[i]).abs
    y = @s[i]
    j = @t.bsearch_index{|z| z >= y}
    if j == 0 then
      d += (y - @t[j]).abs
    elsif j.nil? then
      d += (y - @t[@b - 1]).abs
    else
      if (y - @t[j - 1]).abs < (y - @t[j]).abs then
        d += (y - @t[j - 1]).abs
      else
        d += (y - @t[j]).abs
      end
    end
  elsif i.nil? then
    d = (x - @s[@a - 1]).abs
    y = @s[@a - 1]
    j = @t.bsearch_index{|z| z >= y}
    if j == 0 then
      d += (y - @t[j]).abs
    elsif j.nil? then
      d += (y - @t[@b - 1]).abs
    else
      if (y - @t[j - 1]).abs < (y - @t[j]).abs then
        d += (y - @t[j - 1]).abs
      else
        d += (y - @t[j]).abs
      end
    end
  else
    d1 = (x - @s[i - 1]).abs
    y = @s[i - 1]
    j = @t.bsearch_index{|z| z >= y}
    if j == 0 then
      d1 += (y - @t[j]).abs
    elsif j.nil? then
      d1 += (y - @t[@b - 1]).abs
    else
      if (y - @t[j - 1]).abs < (y - @t[j]).abs then
        d1 += (y - @t[j - 1]).abs
      else
        d1 += (y - @t[j]).abs
      end
    end
    
    d2 = (x - @s[i]).abs
    y = @s[i]
    j = @t.bsearch_index{|z| z >= y}
    if j == 0 then
      d2 += (y - @t[j]).abs
    elsif j.nil? then
      d2 += (y - @t[@b - 1]).abs
    else
      if (y - @t[j - 1]).abs < (y - @t[j]).abs then
        d2 += (y - @t[j - 1]).abs
      else
        d2 += (y - @t[j]).abs
      end
    end
    
    d = [d1, d2].min
  end
  
  return d
end

def route2(x)
  d = 0
  
  i = @t.bsearch_index{|y| y >= x}
  if i == 0 then
    d = (x - @t[i]).abs
    y = @t[i]
    j = @s.bsearch_index{|z| z >= y}
    if j == 0 then
      d += (y - @s[j]).abs
    elsif j.nil? then
      d += (y - @s[@a - 1]).abs
    else
      if (y - @s[j - 1]).abs < (y - @s[j]).abs then
        d += (y - @s[j - 1]).abs
      else
        d += (y - @s[j]).abs
      end
    end
  elsif i.nil? then
    d = (x - @t[@b - 1]).abs
    y = @t[@b - 1]
    j = @s.bsearch_index{|z| z >= y}
    if j == 0 then
      d += (y - @s[j]).abs
    elsif j.nil? then
      d += (y - @s[@a - 1]).abs
    else
      if (y - @s[j - 1]).abs < (y - @s[j]).abs then
        d += (y - @s[j - 1]).abs
      else
        d += (y - @s[j]).abs
      end
    end
  else
    d1 = (x - @t[i - 1]).abs
    y = @t[i - 1]
    j = @s.bsearch_index{|z| z >= y}
    if j == 0 then
      d1 += (y - @s[j]).abs
    elsif j.nil? then
      d1 += (y - @s[@a - 1]).abs
    else
      if (y - @s[j - 1]).abs < (y - @s[j]).abs then
        d1 += (y - @s[j - 1]).abs
      else
        d1 += (y - @s[j]).abs
      end
    end
    
    d2 = (x - @t[i]).abs
    y = @t[i]
    j = @s.bsearch_index{|z| z >= y}
    if j == 0 then
      d2 += (y - @s[j]).abs
    elsif j.nil? then
      d2 += (y - @s[@a - 1]).abs
    else
      if (y - @s[j - 1]).abs < (y - @s[j]).abs then
        d2 += (y - @s[j - 1]).abs
      else
        d2 += (y - @s[j]).abs
      end
    end
    
    d = [d1, d2].min
  end
  
  return d
end

@q.times do |i|
  x = gets.chomp.to_i
  
  puts [route1(x), route2(x)].min.to_s
end

Measured memory_bytes: 4476