import sys
input = sys.stdin.readline
A,B,Q = map(int,input().split())
S = []
for i in range(A):
  temp = int(input())
  S.append(temp)
#S.sort()
T = []
for i in range(B):
  temp = int(input())
  T.append(temp)
#T.sort()
#print(S,T)

def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret

def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P)
for i in range(Q):
  INPUT = int(input())
  j = jinja(INPUT)
  #print(j)
  if len(j) == 2:
    x = j[0]; loc = S[j[1]]
    jt = tera(loc)
    if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
  else:
    x1 = j[0]; loc1 = S[j[1]]; x2 = j[2]; loc2 = S[j[3]]
    jt1 = tera(loc1); jt2 = tera(loc2)
    if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
    if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
    x = min(x1, x2)
  t = tera(INPUT)
  #print(t)
  if len(t) == 2:
    y = t[0]; loc = T[t[1]]
    tj = jinja(loc)
    #print(y,loc,tj)
    if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
  else:
    y1 = t[0]; loc1 = T[t[1]]; y2 = t[2]; loc2 = T[t[3]]
    tj1 = jinja(loc1); tj2 = jinja(loc2)
    if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
    if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
    y = min(y1, y2)
  #print(x,y)
  print(min(x,y)) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline A,B,Q = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B Q S = [] S [] for i in range(A):
  temp = int(input())
  S.append(temp)
#S.sort() i range(A) range A temp = int(input()) temp int(input()) int input() input S.append(temp) S.append S append temp T = [] T [] for i in range(B):
  temp = int(input())
  T.append(temp)
#T.sort()
#print(S,T) i range(B) range B temp = int(input()) temp int(input()) int input() input T.append(temp) T.append T append temp def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret jinja if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
   x <= S[0] x S[0] S 0 ret = [S[0]-x,0] ret [S[0]-x,0] S[0]-x S[0] S 0 x 0 elif x >= S[-1]:
    ret = [x-S[-1],A-1]
   x >= S[-1] x S[-1] S -1 ret = [x-S[-1],A-1] ret [x-S[-1],A-1] x-S[-1] x S[-1] S -1 A-1 A 1 ok = 0 ok 0 ng = A ng A while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
     abs(ok-ng) > 1 abs(ok-ng) abs ok-ng ok ng 1 mid = (ok+ng)//2 mid (ok+ng)//2 ok+ng ok ng 2 if S[mid] <= x:
        ok = mid
      else:
        ng = mid
     S[mid] <= x S[mid] S mid x ok = mid ok mid ng = mid ng mid ret = [x - S[ok],ok,S[ng] - x,ng] ret [x - S[ok],ok,S[ng] - x,ng] x - S[ok] x S[ok] S ok ok S[ng] - x S[ng] S ng x ng return ret ret x x def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P) tera if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
   x <= T[0] x T[0] T 0 ret = [T[0]-x,0] ret [T[0]-x,0] T[0]-x T[0] T 0 x 0 elif x >= T[-1]:
    ret = [x-T[-1],B-1]
   x >= T[-1] x T[-1] T -1 ret = [x-T[-1],B-1] ret [x-T[-1],B-1] x-T[-1] x T[-1] T -1 B-1 B 1 ok = 0 ok 0 ng = B ng B while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
     abs(ok-ng) > 1 abs(ok-ng) abs ok-ng ok ng 1 mid = (ok+ng)//2 mid (ok+ng)//2 ok+ng ok ng 2 if T[mid] <= x:
        ok = mid
      else:
        ng = mid
     T[mid] <= x T[mid] T mid x ok = mid ok mid ng = mid ng mid ret = [x - T[ok],ok,T[ng] - x,ng] ret [x - T[ok],ok,T[ng] - x,ng] x - T[ok] x T[ok] T ok ok T[ng] - x T[ng] T ng x ng return ret ret x x for i in range(Q):
  INPUT = int(input())
  j = jinja(INPUT)
  #print(j)
  if len(j) == 2:
    x = j[0]; loc = S[j[1]]
    jt = tera(loc)
    if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
  else:
    x1 = j[0]; loc1 = S[j[1]]; x2 = j[2]; loc2 = S[j[3]]
    jt1 = tera(loc1); jt2 = tera(loc2)
    if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
    if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
    x = min(x1, x2)
  t = tera(INPUT)
  #print(t)
  if len(t) == 2:
    y = t[0]; loc = T[t[1]]
    tj = jinja(loc)
    #print(y,loc,tj)
    if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
  else:
    y1 = t[0]; loc1 = T[t[1]]; y2 = t[2]; loc2 = T[t[3]]
    tj1 = jinja(loc1); tj2 = jinja(loc2)
    if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
    if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
    y = min(y1, y2)
  #print(x,y)
  print(min(x,y)) i range(Q) range Q INPUT = int(input()) INPUT int(input()) int input() input j = jinja(INPUT) j jinja(INPUT) jinja INPUT if len(j) == 2:
    x = j[0]; loc = S[j[1]]
    jt = tera(loc)
    if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
  else:
    x1 = j[0]; loc1 = S[j[1]]; x2 = j[2]; loc2 = S[j[3]]
    jt1 = tera(loc1); jt2 = tera(loc2)
    if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
    if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
    x = min(x1, x2)
   len(j) == 2 len(j) len j 2 x = j[0] x j[0] j 0 loc = S[j[1]] loc S[j[1]] S j[1] j 1 jt = tera(loc) jt tera(loc) tera loc if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
   len(jt) == 2 len(jt) len jt 2 x += jt[0] x jt[0] jt 0 x += min(jt[0],jt[2]) x min(jt[0],jt[2]) min jt[0] jt 0 jt[2] jt 2 x1 = j[0] x1 j[0] j 0 loc1 = S[j[1]] loc1 S[j[1]] S j[1] j 1 x2 = j[2] x2 j[2] j 2 loc2 = S[j[3]] loc2 S[j[3]] S j[3] j 3 jt1 = tera(loc1) jt1 tera(loc1) tera loc1 jt2 = tera(loc2) jt2 tera(loc2) tera loc2 if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
     len(jt1) == 2 len(jt1) len jt1 2 x1 += jt1[0] x1 jt1[0] jt1 0 x1 += min(jt1[0],jt1[2]) x1 min(jt1[0],jt1[2]) min jt1[0] jt1 0 jt1[2] jt1 2 if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
     len(jt2) == 2 len(jt2) len jt2 2 x2 += jt2[0] x2 jt2[0] jt2 0 x2 += min(jt2[0],jt2[2]) x2 min(jt2[0],jt2[2]) min jt2[0] jt2 0 jt2[2] jt2 2 x = min(x1, x2) x min(x1, x2) min x1 x2 t = tera(INPUT) t tera(INPUT) tera INPUT if len(t) == 2:
    y = t[0]; loc = T[t[1]]
    tj = jinja(loc)
    #print(y,loc,tj)
    if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
  else:
    y1 = t[0]; loc1 = T[t[1]]; y2 = t[2]; loc2 = T[t[3]]
    tj1 = jinja(loc1); tj2 = jinja(loc2)
    if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
    if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
    y = min(y1, y2)
  #print(x,y)
   len(t) == 2 len(t) len t 2 y = t[0] y t[0] t 0 loc = T[t[1]] loc T[t[1]] T t[1] t 1 tj = jinja(loc) tj jinja(loc) jinja loc if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
   len(tj) == 2 len(tj) len tj 2 y += tj[0] y tj[0] tj 0 y += min(tj[0],tj[2]) y min(tj[0],tj[2]) min tj[0] tj 0 tj[2] tj 2 y1 = t[0] y1 t[0] t 0 loc1 = T[t[1]] loc1 T[t[1]] T t[1] t 1 y2 = t[2] y2 t[2] t 2 loc2 = T[t[3]] loc2 T[t[3]] T t[3] t 3 tj1 = jinja(loc1) tj1 jinja(loc1) jinja loc1 tj2 = jinja(loc2) tj2 jinja(loc2) jinja loc2 if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
     len(tj1) == 2 len(tj1) len tj1 2 y1 += tj1[0] y1 tj1[0] tj1 0 y1 += min(tj1[0],tj1[2]) y1 min(tj1[0],tj1[2]) min tj1[0] tj1 0 tj1[2] tj1 2 if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
     len(tj2) == 2 len(tj2) len tj2 2 y2 += tj2[0] y2 tj2[0] tj2 0 y2 += min(tj2[0],tj2[2]) y2 min(tj2[0],tj2[2]) min tj2[0] tj2 0 tj2[2] tj2 2 y = min(y1, y2) y min(y1, y2) min y1 y2 print(min(x,y)) print min(x,y) min x y S = [] [] S x2 += min(jt2[0],jt2[2]) min(jt2[0],jt2[2]) x2 loc = T[t[1]] T[t[1]] loc y += min(tj[0],tj[2]) min(tj[0],tj[2]) y tj2 = jinja(loc2) jinja(loc2) tj2 loc1 = T[t[1]] T[t[1]] loc1 y2 += min(tj2[0],tj2[2]) min(tj2[0],tj2[2]) y2 def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret jinja INPUT = int(input()) int(input()) INPUT x = min(x1, x2) min(x1, x2) x tj1 = jinja(loc1) jinja(loc1) tj1 y += tj[0] tj[0] y y2 = t[2] t[2] y2 y2 += tj2[0] tj2[0] y2 y = min(y1, y2) min(y1, y2) y x1 += min(jt1[0],jt1[2]) min(jt1[0],jt1[2]) x1 B,Q = map(int,input().split()) map(int,input().split()) B tj = jinja(loc) jinja(loc) tj loc2 = S[j[3]] S[j[3]] loc2 temp = int(input()) int(input()) temp y1 += tj1[0] tj1[0] y1 jt2 = tera(loc2) tera(loc2) jt2 x2 = j[2] j[2] x2 x2 += jt2[0] jt2[0] x2 input = sys.stdin.readline sys.stdin.readline input def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P) def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P) tera y1 += min(tj1[0],tj1[2]) min(tj1[0],tj1[2]) y1 y1 = t[0] t[0] y1 loc2 = T[t[3]] T[t[3]] loc2 j = jinja(INPUT) jinja(INPUT) j Q = map(int,input().split()) map(int,input().split()) Q temp = int(input()) int(input()) temp x1 = j[0] j[0] x1 loc1 = S[j[1]] S[j[1]] loc1 x1 += jt1[0] jt1[0] x1 loc = S[j[1]] S[j[1]] loc x += min(jt[0],jt[2]) min(jt[0],jt[2]) x A,B,Q = map(int,input().split()) map(int,input().split()) A x += jt[0] jt[0] x jt = tera(loc) tera(loc) jt t = tera(INPUT) tera(INPUT) t y = t[0] t[0] y T = [] [] T x = j[0] j[0] x jt1 = tera(loc1) tera(loc1) jt1
import sys
input = sys.stdin.readline
A,B,Q = map(int,input().split())
S = []
for i in range(A):
  temp = int(input())
  S.append(temp)
#S.sort()
T = []
for i in range(B):
  temp = int(input())
  T.append(temp)
#T.sort()
#print(S,T)

def jinja(x): #移動距離、神社の位置を出力
  if x <= S[0]:
    ret = [S[0]-x,0]
  elif x >= S[-1]:
    ret = [x-S[-1],A-1]
  else:
    ok = 0
    ng = A
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if S[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - S[ok],ok,S[ng] - x,ng]
  return ret

def tera(x): #移動距離、神社の位置を出力
  if x <= T[0]:
    ret = [T[0]-x,0]
  elif x >= T[-1]:
    ret = [x-T[-1],B-1]
  else:
    ok = 0
    ng = B
    while abs(ok-ng) > 1:
      mid = (ok+ng)//2
      if T[mid] <= x:
        ok = mid
      else:
        ng = mid
    ret = [x - T[ok],ok,T[ng] - x,ng]
  return ret
      

#P = tera(100)
#print(P)
for i in range(Q):
  INPUT = int(input())
  j = jinja(INPUT)
  #print(j)
  if len(j) == 2:
    x = j[0]; loc = S[j[1]]
    jt = tera(loc)
    if len(jt) == 2:
      x += jt[0]
    else:
      x += min(jt[0],jt[2])
  else:
    x1 = j[0]; loc1 = S[j[1]]; x2 = j[2]; loc2 = S[j[3]]
    jt1 = tera(loc1); jt2 = tera(loc2)
    if len(jt1) == 2:
      x1 += jt1[0]
    else:
      x1 += min(jt1[0],jt1[2])
    if len(jt2) == 2:
      x2 += jt2[0]
    else:
      x2 += min(jt2[0],jt2[2])
    x = min(x1, x2)
  t = tera(INPUT)
  #print(t)
  if len(t) == 2:
    y = t[0]; loc = T[t[1]]
    tj = jinja(loc)
    #print(y,loc,tj)
    if len(tj) == 2:
      y += tj[0]
    else:
      y += min(tj[0],tj[2])
  else:
    y1 = t[0]; loc1 = T[t[1]]; y2 = t[2]; loc2 = T[t[3]]
    tj1 = jinja(loc1); tj2 = jinja(loc2)
    if len(tj1) == 2:
      y1 += tj1[0]
    else:
      y1 += min(tj1[0],tj1[2])
    if len(tj2) == 2:
      y2 += tj2[0]
    else:
      y2 += min(tj2[0],tj2[2])
    y = min(y1, y2)
  #print(x,y)
  print(min(x,y))