a,b,q = map(int,input().split())
tl=[]
qlist=[]
for i in range(a):tl.append((int(input()),0,i))
for i in range(b):tl.append((int(input()),1,i))
for i in range(q):
    q1=int(input())
    tl.append((q1,2,i))
    qlist.append(q1)
tl.sort()
prea=[-1]*q
preb=[-1]*q
ta=tb=-1
for i,c in enumerate(tl):
    if   c[1]==0:ta=c[0]
    elif c[1]==1:tb=c[0]
    elif c[1]==2:prea[c[2]],preb[c[2]]=ta,tb
posta=[-1]*q
postb=[-1]*q
ra=rb=-1
for i,c in enumerate(tl[::-1]):
    if   c[1]==0:ra=c[0]
    elif c[1]==1:rb=c[0]
    elif c[1]==2:posta[c[2]],postb[c[2]]=ra,rb

def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin
for a1,a2,b1,b2,q in zip(prea,posta,preb,postb,qlist):print(cal(a1,a2,b1,b2,q)) a,b,q = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b q tl=[] tl [] qlist=[] qlist [] for i in range(a):tl.append((int(input()),0,i)) i range(a) range a for i in range(b):tl.append((int(input()),1,i)) i range(b) range b for i in range(q):
    q1=int(input())
    tl.append((q1,2,i))
    qlist.append(q1) i range(q) range q q1=int(input()) q1 int(input()) int input() input tl.append((q1,2,i)) tl.append tl append (q1,2,i) q1 2 i qlist.append(q1) qlist.append qlist append q1 tl.sort() tl.sort tl sort prea=[-1]*q prea [-1]*q [-1] -1 q preb=[-1]*q preb [-1]*q [-1] -1 q ta=tb=-1 ta -1 =tb=-1 tb -1 for i,c in enumerate(tl):
    if   c[1]==0:ta=c[0]
    elif c[1]==1:tb=c[0]
    elif c[1]==2:prea[c[2]],preb[c[2]]=ta,tb i c enumerate(tl) enumerate tl if   c[1]==0:ta=c[0]
    elif c[1]==1:tb=c[0]
    elif c[1]==2:prea[c[2]],preb[c[2]]=ta,tb c[1]==0 c[1] c 1 0 elif c[1]==1:tb=c[0]
     c[1]==1 c[1] c 1 1 elif c[1]==2:prea[c[2]],preb[c[2]]=t c[1]==2 c[1] c 1 2 posta=[-1]*q posta [-1]*q [-1] -1 q postb=[-1]*q postb [-1]*q [-1] -1 q ra=rb=-1 ra -1 =rb=-1 rb -1 for i,c in enumerate(tl[::-1]):
    if   c[1]==0:ra=c[0]
    elif c[1]==1:rb=c[0]
    elif c[1]==2:posta[c[2]],postb[c[2]]=ra,rb i c enumerate(tl[::-1]) enumerate tl[::-1] tl ::-1 -1 if   c[1]==0:ra=c[0]
    elif c[1]==1:rb=c[0]
    elif c[1]==2:posta[c[2]],postb[c[2]]=ra,rb c[1]==0 c[1] c 1 0 elif c[1]==1:rb=c[0]
     c[1]==1 c[1] c 1 1 elif c[1]==2:posta[c[2]],postb[c[2]]=r c[1]==2 c[1] c 1 2 def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin cal gmin = 999999999999 gmin 999999999999 if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
     pra!=-1 and prb!=-1 pra!=-1 pra -1 prb!=-1 prb -1 if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
     pra<prb pra prb if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
     pra!=-1 and pob!=-1 pra!=-1 pra -1 pob!=-1 pob -1 if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
     prb!=-1 and poa!=-1 prb!=-1 prb -1 poa!=-1 poa -1 if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
     poa!=-1 and pob!=-1 poa!=-1 poa -1 pob!=-1 pob -1 if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
     poa<pob poa pob return gmin gmin pra pra poa poa prb prb pob pob q q for a1,a2,b1,b2,q in zip(prea,posta,preb,postb,qlist):print(cal(a1,a2,b1,b2,q)) a1 a2 b1 b2 q zip(prea,posta,preb,postb,qlist) zip prea posta preb postb qlist b,q = map(int,input().split()) map(int,input().split()) b def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin cal ra=rb=-1 -1 ra preb=[-1]*q [-1]*q preb ta=tb=-1 -1 ta rb=-1 -1 rb qlist=[] [] qlist q = map(int,input().split()) map(int,input().split()) q posta=[-1]*q [-1]*q posta tl=[] [] tl postb=[-1]*q [-1]*q postb a,b,q = map(int,input().split()) map(int,input().split()) a q1=int(input()) int(input()) q1 tb=-1 -1 tb prea=[-1]*q [-1]*q prea
a,b,q = map(int,input().split())
tl=[]
qlist=[]
for i in range(a):tl.append((int(input()),0,i))
for i in range(b):tl.append((int(input()),1,i))
for i in range(q):
    q1=int(input())
    tl.append((q1,2,i))
    qlist.append(q1)
tl.sort()
prea=[-1]*q
preb=[-1]*q
ta=tb=-1
for i,c in enumerate(tl):
    if   c[1]==0:ta=c[0]
    elif c[1]==1:tb=c[0]
    elif c[1]==2:prea[c[2]],preb[c[2]]=ta,tb
posta=[-1]*q
postb=[-1]*q
ra=rb=-1
for i,c in enumerate(tl[::-1]):
    if   c[1]==0:ra=c[0]
    elif c[1]==1:rb=c[0]
    elif c[1]==2:posta[c[2]],postb[c[2]]=ra,rb

def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin
for a1,a2,b1,b2,q in zip(prea,posta,preb,postb,qlist):print(cal(a1,a2,b1,b2,q))