import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large


def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans)


if __name__ == '__main__':
    main() import sys sys import re re import math math import collections collections import bisect bisect import itertools itertools import fractions fractions import functools functools import copy copy import heapq heapq import decimal decimal import statistics statistics import queue queue sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10 ** 16 INF 10 ** 16 10 16 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ni = lambda: int(sys.stdin.readline()) ni lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ns = lambda: map(int, sys.stdin.readline().split()) ns lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na = lambda: list(map(int, sys.stdin.readline().split())) na lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) na1 lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list map(lambda x: int(x) - 1, sys.stdin.readline().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large disLR small = a[max(0, idx - 1)] small a[max(0, idx - 1)] a max(0, idx - 1) max 0 idx - 1 idx 1 large = a[min(len(a) - 1, idx)] large a[min(len(a) - 1, idx)] a min(len(a) - 1, idx) min len(a) - 1 len(a) len a 1 idx return small, large return small, large small large a a idx idx def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans) main a, b, q = ns() a ns() ns b q ni() for _ in range(a) for _ in range(a) _ range(a) range a for _ in range(a) ni() ni s = [ni() for _ in range(a)] s [ni() for _ in range(a)] ni() for _ in range(b) for _ in range(b) _ range(b) range b for _ in range(b) ni() ni t = [ni() for _ in range(b)] t [ni() for _ in range(b)] for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans) _ range(q) range q ans = INF ans INF x = ni() x ni() ni tmpans = [0] * 4 tmpans [0] * 4 [0] 0 4 idxs = bisect.bisect_left(s, x) idxs bisect.bisect_left(s, x) bisect.bisect_left bisect bisect_left s x sml, lrg = disLR(s, idxs) sml disLR(s, idxs) disLR s idxs lrg tmpans[0] += abs(x - sml) tmpans[0] tmpans 0 abs(x - sml) abs x - sml x sml tmpans[1] += abs(x - lrg) tmpans[1] tmpans 1 abs(x - lrg) abs x - lrg x lrg idxsml = bisect.bisect_left(t, sml) idxsml bisect.bisect_left(t, sml) bisect.bisect_left bisect bisect_left t sml abs(sml - i) for i in disLR(t, idxsml) for i in disLR(t, idxsml) i disLR(t, idxsml) disLR t idxsml for i in disLR(t, idxsml) abs(sml - i) abs sml - i sml i tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)]) tmpans[0] tmpans 0 min([abs(sml - i) for i in disLR(t, idxsml)]) min [abs(sml - i) for i in disLR(t, idxsml)] idxlrg = bisect.bisect_left(t, lrg) idxlrg bisect.bisect_left(t, lrg) bisect.bisect_left bisect bisect_left t lrg abs(lrg - i) for i in disLR(t, idxlrg) for i in disLR(t, idxlrg) i disLR(t, idxlrg) disLR t idxlrg for i in disLR(t, idxlrg) abs(lrg - i) abs lrg - i lrg i tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)]) tmpans[1] tmpans 1 min([abs(lrg - i) for i in disLR(t, idxlrg)]) min [abs(lrg - i) for i in disLR(t, idxlrg)] idxt = bisect.bisect_left(t, x) idxt bisect.bisect_left(t, x) bisect.bisect_left bisect bisect_left t x sml, lrg = disLR(t, idxt) sml disLR(t, idxt) disLR t idxt lrg tmpans[2] += abs(x - sml) tmpans[2] tmpans 2 abs(x - sml) abs x - sml x sml tmpans[3] += abs(x - lrg) tmpans[3] tmpans 3 abs(x - lrg) abs x - lrg x lrg idxsml = bisect.bisect_left(s, sml) idxsml bisect.bisect_left(s, sml) bisect.bisect_left bisect bisect_left s sml abs(sml - i) for i in disLR(s, idxsml) for i in disLR(s, idxsml) i disLR(s, idxsml) disLR s idxsml for i in disLR(s, idxsml) abs(sml - i) abs sml - i sml i tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)]) tmpans[2] tmpans 2 min([abs(sml - i) for i in disLR(s, idxsml)]) min [abs(sml - i) for i in disLR(s, idxsml)] idxlrg = bisect.bisect_left(s, lrg) idxlrg bisect.bisect_left(s, lrg) bisect.bisect_left bisect bisect_left s lrg abs(lrg - i) for i in disLR(s, idxlrg) for i in disLR(s, idxlrg) i disLR(s, idxlrg) disLR s idxlrg for i in disLR(s, idxlrg) abs(lrg - i) abs lrg - i lrg i tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)]) tmpans[3] tmpans 3 min([abs(lrg - i) for i in disLR(s, idxlrg)]) min [abs(lrg - i) for i in disLR(s, idxlrg)] ans = min(ans, min(tmpans)) ans min(ans, min(tmpans)) min ans min(tmpans) min tmpans print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans) def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans) main na = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) na na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) na1 def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large disLR MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = 10 ** 16 10 ** 16 INF ns = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) ns ni = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ni
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large


def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans)


if __name__ == '__main__':
    main()
