output_description: If A is a divisor of B, print A + B; otherwise, print B - A.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      A B
attempt: import bisect
  
  f_inf = float("inf")
  
  
  def cal(syurui, d, index):
      if d == "e":
          return syurui[index]
      elif d == "w":
          return syurui[index - 1]
  
  
  A, B, Q = map(int, input().split())
  s = [int(input()) for i in range(A)]
  s.sort()
  t = [int(input()) for i in range(B)]
  t.sort()
  
  for i in range(Q):
      x = int(input())
      s_index = bisect.bisect_left(s, x)
      t_index = bisect.bisect_left(t, x)
      if s_index == len(s) and t_index == len(t):
          print(max(abs(x - s[s_index - 1]), abs(x - t[t_index - 1])))
      elif s_index == len(s):
          ｓ.insert(0, -f_inf)
          t.insert(0, -f_inf)
          print(
              min(
                  max(abs(x - s[s_index]), abs(x - t[t_index])),
                  2 * abs(x - s[s_index]) + abs(x - t[t_index + 1]),
                  abs(x - s[s_index]) + 2 * abs(x - t[t_index + 1]),
              )
          )
      elif t_index == len(t):
          ｓ.insert(0, -f_inf)
          t.insert(0, -f_inf)
          print(
              min(
                  max(abs(x - s[s_index]), abs(x - t[t_index])),
                  2 * abs(x - s[s_index + 1]) + abs(x - t[t_index]),
                  abs(x - s[s_index + 1]) + 2 * abs(x - t[t_index]),
              )
          )
      else:
          ｓ.insert(0, -f_inf)
          t.insert(0, -f_inf)
          print(
              min(
                  max(abs(x - s[s_index]), abs(x - t[t_index])),
                  max(abs(x - s[s_index + 1]), abs(x - t[t_index + 1])),
                  2 * abs(x - s[s_index + 1]) + abs(x - t[t_index]),
                  2 * abs(x - s[s_index]) + abs(x - t[t_index + 1]),
                  abs(x - s[s_index + 1]) + 2 * abs(x - t[t_index]),
                  abs(x - s[s_index]) + 2 * abs(x - t[t_index + 1]),
              )
          )
  
problem_description: Statement
  
  You are given positive integers A and B.
  
  If A is a divisor of B, print A + B; otherwise, print B - A.
samples: [{"input": "4 12", "output": "16\n    \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n    \n\n* * *"}, {"input": "1 1", "output": "2\n    \n\n1 is a divisor of 1."}]