Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

import numpy as np
for i in x:
    #s->t
    st = np.nanmin(np.array([abs(s[bisect.bisect(s, i)] - i) + abs(s[bisect.bisect(s, i)] - t[bisect.bisect(t, i)]), \
             abs(s[bisect.bisect(s, i)-1] - i) + abs(s[bisect.bisect(s, i)-1] - t[bisect.bisect(t, i)]), \
             abs(s[bisect.bisect(s, i)] - i) + abs(s[bisect.bisect(s, i)] - t[bisect.bisect(t, i)-1]), \
             abs(s[bisect.bisect(s, i)-1] - i) + abs(s[bisect.bisect(s, i)-1] - t[bisect.bisect(t, i)-1])]))
    #t->s
    ts = np.nanmin(np.array([abs(t[bisect.bisect(t, i)] - i) + abs(t[bisect.bisect(t, i)] - s[bisect.bisect(s, i)]), \
             abs(t[bisect.bisect(t, i)-1] - i) + abs(t[bisect.bisect(t, i)-1] - s[bisect.bisect(s, i)]), \
             abs(t[bisect.bisect(t, i)] - i) + abs(t[bisect.bisect(t, i)] - s[bisect.bisect(s, i)-1]), \
             abs(t[bisect.bisect(t, i)-1] - i) + abs(t[bisect.bisect(t, i)-1] - s[bisect.bisect(s, i)-1])]))
    print(int(min(st, ts)))

Fixed submission:
import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, q = map(int, input().split())
s = []
t = []
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
    
import numpy as np
s = np.array(s)
t = np.array(t)

for i in x:
    ans_st = 0
    ans_ts = 0
    # s -> t
    ans_st += min(abs(s-i))
    ans_st += min(abs(t - s[list(abs(s-i)).index(min(abs(s-i)))]))
    
    # t->s
    ans_ts += min(abs(t-i))
    ans_ts += min(abs(s - t[list(abs(t-i)).index(min(abs(t-i)))]))
    
    print(min(ans_st, ans_ts))

Fixed submission:
import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et))