import bisect
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()

"""
sとtのどちらを先にするか
左右どちらに走るか
の都合4パターンの最小値を選べばよい
"""

def minl(x):
    # sを選択
    idx = bisect.bisect_left(s, x)
    ret = 3*10**10
    if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
    idx = bisect.bisect_left(t, x)
    if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
    return ret

for i in range(q):
    x = int(input())
    print(minl(x)) import bisect bisect a, b, q = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b q int(input()) for i in range(a) for i in range(a) i range(a) range a for i in range(a) int(input()) int input() input s = [int(input()) for i in range(a)] s [int(input()) for i in range(a)] s.sort() s.sort s sort int(input()) for i in range(b) for i in range(b) i range(b) range b for i in range(b) int(input()) int input() input t = [int(input()) for i in range(b)] t [int(input()) for i in range(b)] t.sort() t.sort t sort """
sとtのどちらを先にするか
左右どちらに走るか
の都合4パターンの最小値を選べばよい
""" def minl(x):
    # sを選択
    idx = bisect.bisect_left(s, x)
    ret = 3*10**10
    if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
    idx = bisect.bisect_left(t, x)
    if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
    return ret minl idx = bisect.bisect_left(s, x) idx bisect.bisect_left(s, x) bisect.bisect_left bisect bisect_left s x ret = 3*10**10 ret 3*10**10 3 10**10 10 10 if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
     idx == 0 idx 0 first = s[0] - x first s[0] - x s[0] s 0 x now = s[0] now s[0] s 0 idx = bisect.bisect_left(t, now) idx bisect.bisect_left(t, now) bisect.bisect_left bisect bisect_left t now if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
         idx == 0 idx 0 second = t[0] - now second t[0] - now t[0] t 0 now elif idx == b:
            second = now - t[b-1]
         idx == b idx b second = now - t[b-1] second now - t[b-1] now t[b-1] t b-1 b 1 second = min(now - t[idx-1], t[idx]-now) second min(now - t[idx-1], t[idx]-now) min now - t[idx-1] now t[idx-1] t idx-1 idx 1 t[idx]-now t[idx] t idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
     idx == a idx a first = x - s[a-1] first x - s[a-1] x s[a-1] s a-1 a 1 now = s[a-1] now s[a-1] s a-1 a 1 idx = bisect.bisect_left(t, now) idx bisect.bisect_left(t, now) bisect.bisect_left bisect bisect_left t now if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
         idx == 0 idx 0 second = t[0] - now second t[0] - now t[0] t 0 now elif idx == b:
            second = now - t[b-1]
         idx == b idx b second = now - t[b-1] second now - t[b-1] now t[b-1] t b-1 b 1 second = min(now - t[idx-1], t[idx]-now) second min(now - t[idx-1], t[idx]-now) min now - t[idx-1] now t[idx-1] t idx-1 idx 1 t[idx]-now t[idx] t idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
     first_g [s[idx-1], s[idx]] s[idx-1] s idx-1 idx 1 s[idx] s idx first = abs(first_g - x) first abs(first_g - x) abs first_g - x first_g x now = first_g now first_g idx = bisect.bisect_left(t, now) idx bisect.bisect_left(t, now) bisect.bisect_left bisect bisect_left t now if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
             idx == 0 idx 0 second = t[0] - now second t[0] - now t[0] t 0 now elif idx == b:
                second = now - t[b-1]
             idx == b idx b second = now - t[b-1] second now - t[b-1] now t[b-1] t b-1 b 1 second = min(now - t[idx-1], t[idx]-now) second min(now - t[idx-1], t[idx]-now) min now - t[idx-1] now t[idx-1] t idx-1 idx 1 t[idx]-now t[idx] t idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second idx = bisect.bisect_left(t, x) idx bisect.bisect_left(t, x) bisect.bisect_left bisect bisect_left t x if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
     idx == 0 idx 0 first = t[0] - x first t[0] - x t[0] t 0 x now = t[0] now t[0] t 0 idx = bisect.bisect_left(s, now) idx bisect.bisect_left(s, now) bisect.bisect_left bisect bisect_left s now if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
         idx == 0 idx 0 second = s[0] - now second s[0] - now s[0] s 0 now elif idx == a:
            second = now - s[a-1]
         idx == a idx a second = now - s[a-1] second now - s[a-1] now s[a-1] s a-1 a 1 second = min(now - s[idx-1], s[idx]-now) second min(now - s[idx-1], s[idx]-now) min now - s[idx-1] now s[idx-1] s idx-1 idx 1 s[idx]-now s[idx] s idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
     idx == b idx b first = x - t[b-1] first x - t[b-1] x t[b-1] t b-1 b 1 now = t[b-1] now t[b-1] t b-1 b 1 idx = bisect.bisect_left(s, now) idx bisect.bisect_left(s, now) bisect.bisect_left bisect bisect_left s now if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
         idx == 0 idx 0 second = s[0] - now second s[0] - now s[0] s 0 now elif idx == a:
            second = now - s[a-1]
         idx == a idx a second = now - s[a-1] second now - s[a-1] now s[a-1] s a-1 a 1 second = min(now - s[idx-1], s[idx]-now) second min(now - s[idx-1], s[idx]-now) min now - s[idx-1] now s[idx-1] s idx-1 idx 1 s[idx]-now s[idx] s idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
     first_g [t[idx-1], t[idx]] t[idx-1] t idx-1 idx 1 t[idx] t idx first = abs(first_g - x) first abs(first_g - x) abs first_g - x first_g x now = first_g now first_g idx = bisect.bisect_left(s, now) idx bisect.bisect_left(s, now) bisect.bisect_left bisect bisect_left s now if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
             idx == 0 idx 0 second = s[0] - now second s[0] - now s[0] s 0 now elif idx == a:
                second = now - s[a-1]
             idx == a idx a second = now - s[a-1] second now - s[a-1] now s[a-1] s a-1 a 1 second = min(now - s[idx-1], s[idx]-now) second min(now - s[idx-1], s[idx]-now) min now - s[idx-1] now s[idx-1] s idx-1 idx 1 s[idx]-now s[idx] s idx now ret = min(ret, first+second) ret min(ret, first+second) min ret first+second first second return ret ret x x for i in range(q):
    x = int(input())
    print(minl(x)) i range(q) range q x = int(input()) x int(input()) int input() input print(minl(x)) print minl(x) minl x q = map(int, input().split()) map(int, input().split()) q def minl(x):
    # sを選択
    idx = bisect.bisect_left(s, x)
    ret = 3*10**10
    if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
    idx = bisect.bisect_left(t, x)
    if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
    return ret def minl(x):
    # sを選択
    idx = bisect.bisect_left(s, x)
    ret = 3*10**10
    if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
    idx = bisect.bisect_left(t, x)
    if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
    return ret minl a, b, q = map(int, input().split()) map(int, input().split()) a b, q = map(int, input().split()) map(int, input().split()) b s = [int(input()) for i in range(a)] [int(input()) for i in range(a)] s t = [int(input()) for i in range(b)] [int(input()) for i in range(b)] t x = int(input()) int(input()) x
import bisect
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()

"""
sとtのどちらを先にするか
左右どちらに走るか
の都合4パターンの最小値を選べばよい
"""

def minl(x):
    # sを選択
    idx = bisect.bisect_left(s, x)
    ret = 3*10**10
    if idx == 0:
        first = s[0] - x
        now = s[0]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    elif idx == a:
        first = x - s[a-1]
        now = s[a-1]
        idx = bisect.bisect_left(t, now)
        if idx == 0:
            second = t[0] - now
        elif idx == b:
            second = now - t[b-1]
        else:
            second = min(now - t[idx-1], t[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [s[idx-1], s[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(t, now)
            if idx == 0:
                second = t[0] - now
            elif idx == b:
                second = now - t[b-1]
            else:
                second = min(now - t[idx-1], t[idx]-now)
            ret = min(ret, first+second)
    
    # tを選択
    idx = bisect.bisect_left(t, x)
    if idx == 0:
        first = t[0] - x
        now = t[0]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    elif idx == b:
        first = x - t[b-1]
        now = t[b-1]
        idx = bisect.bisect_left(s, now)
        if idx == 0:
            second = s[0] - now
        elif idx == a:
            second = now - s[a-1]
        else:
            second = min(now - s[idx-1], s[idx]-now)
        ret = min(ret, first+second)
    else:
        for first_g in [t[idx-1], t[idx]]:
            first = abs(first_g - x)
            now = first_g
            idx = bisect.bisect_left(s, now)
            if idx == 0:
                second = s[0] - now
            elif idx == a:
                second = now - s[a-1]
            else:
                second = min(now - s[idx-1], s[idx]-now)
            ret = min(ret, first+second)
    return ret

for i in range(q):
    x = int(input())
    print(minl(x))