Problem: Along a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road.  Answer the following Q queries:    * Query i (1 \leq i \leq Q): If we start from a point at a distance of x_i meters from the west end of the road and freely travel along the road, what is the minimum distance that needs to be traveled in order to visit one shrine and one temple? (It is allowed to pass by more shrines and temples than required.)

Submission attempts (in order):
#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return None
        else:
            return search(avl_left[root],key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return None
        else:
            return search(avl_right[root],key)
    return root


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return lower_key
        else:
            return search_lower(avl_left[root],key,lower_key)
    if avl_key[root] < key:
        lower_key = avl_key[root]
        if avl_right[root] == None:
            return lower_key
        else:
            return search_lower(avl_right[root],key,lower_key)
    
    # == 
    return key



def search_higher(root,key,higher_key):
    if avl_key[root] > key:
        higher_key = avl_key[root]
        if avl_left[root] == None:
            return higher_key
        else:
            return search_higher(avl_left[root],key,higher_key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return higher_key
        else:
            return search_higher(avl_right[root],key,higher_key)
    
    # == 
    return key




def DoubleRightRotation(x):
    tl = avl_left[x]
    avl_left[x] = avl_right[avl_right[tl]]
    avl_right[avl_right[tl]] = x
    tlr = avl_right[tl]
    avl_right[tl] = avl_left[tlr]
    avl_left[tlr] = tl
    if balance[tlr] == -1:
        balance[avl_right[tlr]] = 1
        balance[avl_left[tlr]] = 0
    elif balance[tlr] == 1:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = -1
    else:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl_right[x]
    avl_right[x] = avl_left[avl_left[tr]]
    avl_left[avl_left[tr]] = x
    trl = avl_left[tl]
    avl_left[tr] = avl_right[trl]
    avl_right[trl] = tr
    if balance[trl] == 1:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = -1
    elif balance[trl] == -1:
        balance[avl_left[trl]] = 0
        balance[avl_right[trl]] = 1
    else:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl_right[x]
    balance[tr] = 0
    balance[x] = 0
    avl_right[x] = avl_left[tr]
    avl_left[tr] = x
    return tr

def SingleRightRotaion(x):
    tl = avl_left[x]
    balance[tl] = 0
    balance[x] = 0
    avl_left[x] = avl_right[tl]
    avl_right[tl] = x
    return tl

def replace(x,p,v):
    if avl_left[p] == x:
        avl_left[p] = v
    else:
        avl_right[p] = v

def insertx(root,p,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            if not insertx(avl_left[root],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl_left[root]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl_left[root]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl_key[root] < key:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            if not insertx(avl_right[root],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl_right[root]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl_right[root]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl_key[root]:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            insertx(avl_left[root],root,key)
    elif key > avl_key[root]:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            insertx(avl_right[root],root,key)
    else:
        pass

########################################################



#balance[i]: {"Even":0,"Left":-1,"Right":1}


a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]

avl_key = [s[0]]
avl_left = [None]*(a+2)
avl_right = [None]*(a+2)
balance = [0]*(a+2)
for i in range(1,a):
    insert(0,s[i])
insert(0,float("inf"))
insert(0,-float("inf"))

for i in range(q):
    print(search_higher(0,x[i],None))
    print(search_lower(0,x[i],None))

avl_key = [t[0]]
avl_left = [None]*(b+2)
avl_right = [None]*(b+2)
balance = [0]*(b+2)
for i in range(1,b):
    insert(0,t[i])
insert(0,float("inf"))
insert(0,-float("inf"))
for i in range(q):
    print(search_higher(0,x[i],None))
    print(search_lower(0,x[i],None))


import sys
input = sys.stdin.readline
#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return None
        else:
            return search(avl[root][1],key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return None
        else:
            return search(avl[root][2],key)
    return root



def end_lower(root):
    if avl[root][1] == None:
        return avl[root][0]
    else:
        return end_lower(avl[root][1])

def end_higher(root):
    if avl[root][2] == None:
        return avl[root][0]
    else:
        return end_higher(avl[root][2])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_lower(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_lower(avl[root][2],key,lower_key)
    
    # == 
    if avl[root][1] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl[root][1])
        else:
            return max(lower_key,end_higher[root][1])



def search_higher(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_higher(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_higher(avl[root][2],key,higher_key)
    
    # == 
    if avl[root][1] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl[root][1])
        else:
            return min(higher_key,end_lower[root][1])

##search_less(0,x,None):O(logN)

def search_less(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_less(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_less(avl[root][2],key,lower_key)
    
    # == 
    return key

##search_more(0,x,None):O(logN)

def search_more(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_more(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_more(avl[root][2],key,higher_key)
    
    # == 
    return key



def DoubleRightRotation(x):
    tl = avl[x][1]
    avl[x][1] = avl[avl[tl][2]][2]
    avl[avl[tl][2]][2] = x
    tlr = avl[tl][2]
    avl[tl][2] = avl[tlr][1]
    avl[tlr][1] = tl
    if balance[tlr] == -1:
        balance[avl[tlr][2]] = 1
        balance[avl[tlr][1]] = 0
    elif balance[tlr] == 1:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = -1
    else:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl[x][2]
    avl[x][2] = avl[avl[tr][1]][1]
    avl[avl[tr][1]][1] = x
    trl = avl[tl][1]
    avl[tr][1] = avl[trl][2]
    avl[trl][2] = tr
    if balance[trl] == 1:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = -1
    elif balance[trl] == -1:
        balance[avl[trl][1]] = 0
        balance[avl[trl][2]] = 1
    else:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl[x][2]
    balance[tr] = 0
    balance[x] = 0
    avl[x][2] = avl[tr][1]
    avl[tr][1] = x
    return tr

def SingleRightRotaion(x):
    tl = avl[x][1]
    balance[tl] = 0
    balance[x] = 0
    avl[x][1] = avl[tl][2]
    avl[tl][2] = x
    return tl

def replace(x,p,v):
    if avl[p][1] == x:
        avl[p][1] = v
    else:
        avl[p][2] = v

def insertx(root,p,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            avl.append([key,None,None])
            avl[root][1] = len(avl)-1
        else:
            if not insertx(avl[root][1],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl[root][1]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl[root][1]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl[root][0] < key:
        if avl[root][2] == None:
            avl.append([key,None,None])
            avl[root][2] = len(avl)-1
        else:
            if not insertx(avl[root][2],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl[root][2]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl[root][2]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl[root][0]:
        if avl[root][1] == None:
            avl.append([key,None,None])
            avl[root][1] = len(avl)-1
        else:
            insertx(avl[root][1],root,key)
    elif key > avl[root][0]:
        if avl[root][2] == None:
            avl.append([key,None,None])
            avl[root][2] = len(avl)-1
        else:
            insertx(avl[root][2],root,key)
    else:
        pass

########################################################

import sys
input = sys.stdin.readline
a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
#avl[i]:[key,left_index,right_index]
#balance[i]: {"Even":0,"Left":-1,"Right":1}

#N_MAX = 1000000000
avl = [[s[0],None,None]]
balance = [0]*(a)


#avl.append(first_avl)

for i in range(1,a):
    insert(0,s[i])
print(1)

#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return None
        else:
            return search(avl_left[root],key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return None
        else:
            return search(avl_right[root],key)
    return root



def end_lower(root):
    if avl_left[root] == None:
        return avl_key[root]
    else:
        return end_lower(avl_left[root])

def end_higher(root):
    if avl_right[root] == None:
        return avl_key[root]
    else:
        return end_higher(avl_right[root])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return lower_key
        else:
            return search_lower(avl_left[root],key,lower_key)
    if avl_key[root] < key:
        lower_key = avl_key[root]
        if avl_right[root] == None:
            return lower_key
        else:
            return search_lower(avl_right[root],key,lower_key)
    
    # == 
    if avl_left[root] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl_left[root])
        else:
            return max(lower_key,end_higher(avl_left[root]))



def search_higher(root,key,higher_key):
    if avl_key[root] > key:
        higher_key = avl_key[root]
        if avl_left[root] == None:
            return higher_key
        else:
            return search_higher(avl_left[root],key,higher_key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return higher_key
        else:
            return search_higher(avl_right[root],key,higher_key)
    
    # == 
    if avl_right[root] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl_right[root])
        else:
            return min(higher_key,end_lower(avl_right[root]))




def DoubleRightRotation(x):
    tl = avl_left[x]
    avl_left[x] = avl_right[avl_right[tl]]
    avl_right[avl_right[tl]] = x
    tlr = avl_right[tl]
    avl_right[tl] = avl_left[tlr]
    avl_left[tlr] = tl
    if balance[tlr] == -1:
        balance[avl_right[tlr]] = 1
        balance[avl_left[tlr]] = 0
    elif balance[tlr] == 1:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = -1
    else:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl_right[x]
    avl_right[x] = avl_left[avl_left[tr]]
    avl_left[avl_left[tr]] = x
    trl = avl_left[tl]
    avl_left[tr] = avl_right[trl]
    avl_right[trl] = tr
    if balance[trl] == 1:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = -1
    elif balance[trl] == -1:
        balance[avl_left[trl]] = 0
        balance[avl_right[trl]] = 1
    else:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl_right[x]
    balance[tr] = 0
    balance[x] = 0
    avl_right[x] = avl_left[tr]
    avl_left[tr] = x
    return tr

def SingleRightRotaion(x):
    tl = avl_left[x]
    balance[tl] = 0
    balance[x] = 0
    avl_left[x] = avl_right[tl]
    avl_right[tl] = x
    return tl

def replace(x,p,v):
    if avl_left[p] == x:
        avl_left[p] = v
    else:
        avl_right[p] = v

def insertx(root,p,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            if not insertx(avl_left[root],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl_left[root]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl_left[root]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl_key[root] < key:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            if not insertx(avl_right[root],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl_right[root]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl_right[root]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl_key[root]:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            insertx(avl_left[root],root,key)
    elif key > avl_key[root]:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            insertx(avl_right[root],root,key)
    else:
        pass

########################################################



#balance[i]: {"Even":0,"Left":-1,"Right":1}


a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
avl_key = [s]
avl_left = [None]*a
avl_right = [None]*a
balance = [0]*a

for i in range(1,a):
    insert(0,s[i])
t = [int(input()) for i in range(b)]
avl_key = [t[0]]
avl_left = [None]*b
avl_right = [None]*b
balance = [0]*b
for i in range(1,b):
    insert(0,t[i])

print(1)

import sys
# coding: utf-8
#

#
#           Copyright (C) 2007 Makoto Hiroi
#


class Node:
    def __init__(self, x):
        self.data  = x
        self.left  = None
        self.right = None


def rotate_right(node):
    lnode = node.left
    node.left = lnode.right
    lnode.right = node
    return lnode


def rotate_left(node):
    rnode = node.right
    node.right = rnode.left
    rnode.left = node
    return rnode


def search(node, x):
    while node is not None:
        if node.data == x: return True
        if x < node.data:
            node = node.left
        else:
            node = node.right
    return False


def insert(node, x):
    if node is None: return Node(x)
    p = node
    while True:
        if p.data == x: return node
        elif x < p.data:
            if p.left is None:
                p.left = Node(x)
                break
            p = p.left
        else:
            if p.right is None:
                p.right = Node(x)
                break
            p = p.right
    return node

#

#


def _search(node, x):
    pnode = None
    while node is not None:
        if node.data == x: return node, pnode
        pnode = node
        if x < node.data:
            node = node.left
        else:
            node = node.right
    return None, None


def _search_min(node):
    pnode = None
    while node.left is not None:
        pnode = node
        node = node.left
    return node, pnode


def delete(root, x):
    if root is None: return None    
    node, pnode = _search(root, x)  
    if node is None: return root    データなし
    if node.left is not None and node.right is not None:
        
        
        min_node, min_pnode = _search_min(node.right)
        node.data = min_node.data
        if min_pnode is not None:
            pnode = min_pnode
            node = min_node
        else:
            pnode = node
            node = min_node
    
    if node.left is None:
        cnode = node.right
    else:
        cnode = node.left
    if pnode is None:
        return cnode            
    elif pnode.left == node:
        pnode.left = cnode
    else:
        pnode.right = cnode
    return root


def traverse(node):
    if node is not None:
        for x in traverse(node.left):
            yield x
        yield node.data
        for x in traverse(node.right):
            yield x
 
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]
lens, lent = len(s), len(t)
treeA= Node(s[0])
for i in range(1,lens): 
    insert(treeA,s[i]) 
treeB= Node(t[0])
for i in range(lent):
    insert(treeB,t[i])
print(1)


import bisect
import sys
 
class Avltree:
    def __init__(self,key=None):
        self.key = key
        self.left = None
        self.right = None 
        self.balance = "Even"
    def search(self,key):
        if self.key == None:
            return None
        if self.key > key:
            if self.left == None:
                return None
            else:
                return self.left.search(key)
        if self.key < key:
            if self.right == None:
                return None
            else:
                return self.right.search(key)
        return self 
        
    def search_lower(self,key,key_lower):
        if self.key == None:
            return key_lower
        if self.key > key:
            if self.left == None:
                return key_lower
            else:
                return self.left.search_lower(key,key_lower)
        if self.key < key:
            key_lower = self.key
            if self.right == None:
                return key_lower
            else:
                return self.right.search_lower(key,key_lower)
        
        if self.left == None:
            return key_lower
        else:
            if key_lower == None:
                return self.left.end_higher(self.left.key)
            else:
                return max(key_lower,self.left.end_higher(self.left.key))
    
    def search_higher(self,key,key_higher):
        if self.key == None:
            return key_higher
        if self.key > key:
            key_higher = self.key
            if self.left == None:
                return key_higher
            else:
                return self.left.search_higher(key,key_higher)
        if self.key < key:
            if self.right == None:
                return key_higher
            else:
                return self.right.search_higher(key,key_higher)
        
        if self.right == None:
            return key_higher
        else:
            if key_higher == None:
                return self.right.end_lower(self.right.key)
            else:
                return min(key_higher,self.right.end_lower(self.right.key))
        
    
    def end_lower(self,end_lower_key):
        if self.left == None:
            return end_lower_key
        else:
            end_lower_key = self.left.key
            return self.left.end_lower(end_lower_key)
    def end_higher(self,end_higher_key):
        if self.right == None:
            return end_higher_key
        else:
            end_higher_key = self.right.key
            return self.right.end_higher(end_higher_key)
    
            
    def DoubleRightRotation(self):
        tl = self.left
        self.left = tl.right.right
        tl.right.right = self 
        tlr = tl.right
        tl.right = tlr.left
        tlr.left = tl
        if tlr.balance == "Left":
            tlr.right.balance = "Right"
            tlr.left.balance = "Even"
        elif tlr.balance == "Right":
            tlr.right.balance = "Even"
            tlr.left.balance = "Left"
        elif tlr.balance == "Even":
            tlr.right.balance = "Even"
            tlr.left.balance = "Even"
        tlr.balance = "Even"
        return tlr
    def DoubleLeftRotation(self):
        tr = self.right
        self.right = tr.left.left
        tr.left.left = self
        trl = tr.left
        tr.left = trl.right
        trl.right = tr
        if trl.balance == "Right":
            trl.left.balance = "Left"
            trl.right.balance = "Even"
        elif trl.balance == "Left":
            trl.left.balance = "Even"
            trl.right.balance = "Right"
        elif trl.balance == "Even":
            trl.left.balance = "Even"
            trl.right.balance = "Even"
        trl.balance = "Even"
        return trl
    def SingleLeftRotation(self):
        tr = self.right
        tr.balance = "Even"
        self.balance = "Even"
        self.right = tr.left
        tr.left = self
        return tr
    def SingleRightRotation(self):
        tl = self.left
        tl.balance = "Even"
        self.balance = "Even"
        self.left = tl.right
        tl.right = self
        return tl
    def replace(self,p,v): 
        if p.left == self:
            p.left = v
        else :
            p.right = v 
    def insert(self,key): 
        if self.key == None: 
            self.key = key
            return self
        if key < self.key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                self.left.insertx(self,key)
        elif key > self.key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                self.right.insertx(self,key)
        else: # key == self.key:
            pass # do not overwrite
    def insertx(self,p,key): 
        if self.key > key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                if not self.left.insertx(self, key): 
                    return False 
            if self.balance == "Right":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Left"
                return True 
            elif self.balance == "Left":
                if self.left.balance == "Right":
                    self.replace(p,self.DoubleRightRotation())
                elif self.left.balance == "Left":
                    self.replace(p,self.SingleRightRotation())
                return False 
        if self.key < key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                if not self.right.insertx(self, key):
                    return False 
            if self.balance == "Left":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Right"
                return True
            elif self.balance == "Right":
                if self.right.balance == "Left": 
                    self.replace(p,self.DoubleLeftRotation())
                elif self.right.balance == "Right":
                    self.replace(p,self.SingleLeftRotation())
                return False
        return False 
 
    def to_s(self):
        return self.key
    def left_s(self):
        if self.left == None:
            return None
        return (self.left).key
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).key
        
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]
lens, lent = len(s), len(t)
treeA, treeB = Avltree(), Avltree()
for i in s: treeA.insert(i) 
for i in t: treeB.insert(i)
 
print(1)

import sys
 
class Avltree:
    def __init__(self,key=None):
        self.key = key
        self.left = None
        self.right = None 
        self.balance = "Even"
    def search(self,key):
        if self.key == None:
            return None
        if self.key > key:
            if self.left == None:
                return None
            else:
                return self.left.search(key)
        if self.key < key:
            if self.right == None:
                return None
            else:
                return self.right.search(key)
        return self 
        
    def search_lower(self,key,key_lower):
        if self.key == None:
            return key_lower
        if self.key > key:
            if self.left == None:
                return key_lower
            else:
                return self.left.search_lower(key,key_lower)
        if self.key < key:
            key_lower = self.key
            if self.right == None:
                return key_lower
            else:
                return self.right.search_lower(key,key_lower)
        
        if self.left == None:
            return key_lower
        else:
            if key_lower == None:
                return self.left.end_higher(self.left.key)
            else:
                return max(key_lower,self.left.end_higher(self.left.key))
    
    def search_higher(self,key,key_higher):
        if self.key == None:
            return key_higher
        if self.key > key:
            key_higher = self.key
            if self.left == None:
                return key_higher
            else:
                return self.left.search_higher(key,key_higher)
        if self.key < key:
            if self.right == None:
                return key_higher
            else:
                return self.right.search_higher(key,key_higher)
        
        if self.right == None:
            return key_higher
        else:
            if key_higher == None:
                return self.right.end_lower(self.right.key)
            else:
                return min(key_higher,self.right.end_lower(self.right.key))
        
    
    def end_lower(self,end_lower_key):
        if self.left == None:
            return end_lower_key
        else:
            end_lower_key = self.left.key
            return self.left.end_lower(end_lower_key)
    def end_higher(self,end_higher_key):
        if self.right == None:
            return end_higher_key
        else:
            end_higher_key = self.right.key
            return self.right.end_higher(end_higher_key)
    
            
    def DoubleRightRotation(self):
        tl = self.left
        self.left = tl.right.right
        tl.right.right = self 
        tlr = tl.right
        tl.right = tlr.left
        tlr.left = tl
        if tlr.balance == "Left":
            tlr.right.balance = "Right"
            tlr.left.balance = "Even"
        elif tlr.balance == "Right":
            tlr.right.balance = "Even"
            tlr.left.balance = "Left"
        elif tlr.balance == "Even":
            tlr.right.balance = "Even"
            tlr.left.balance = "Even"
        tlr.balance = "Even"
        return tlr
    def DoubleLeftRotation(self):
        tr = self.right
        self.right = tr.left.left
        tr.left.left = self
        trl = tr.left
        tr.left = trl.right
        trl.right = tr
        if trl.balance == "Right":
            trl.left.balance = "Left"
            trl.right.balance = "Even"
        elif trl.balance == "Left":
            trl.left.balance = "Even"
            trl.right.balance = "Right"
        elif trl.balance == "Even":
            trl.left.balance = "Even"
            trl.right.balance = "Even"
        trl.balance = "Even"
        return trl
    def SingleLeftRotation(self):
        tr = self.right
        tr.balance = "Even"
        self.balance = "Even"
        self.right = tr.left
        tr.left = self
        return tr
    def SingleRightRotation(self):
        tl = self.left
        tl.balance = "Even"
        self.balance = "Even"
        self.left = tl.right
        tl.right = self
        return tl
    def replace(self,p,v): 
        if p.left == self:
            p.left = v
        else :
            p.right = v 
    def insert(self,key): 
        if self.key == None: 
            self.key = key
            return self
        if key < self.key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                self.left.insertx(self,key)
        elif key > self.key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                self.right.insertx(self,key)
        else: # key == self.key:
            pass # do not overwrite
    def insertx(self,p,key): 
        if self.key > key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                if not self.left.insertx(self, key): 
                    return False 
            if self.balance == "Right":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Left"
                return True 
            elif self.balance == "Left":
                if self.left.balance == "Right":
                    self.replace(p,self.DoubleRightRotation())
                elif self.left.balance == "Left":
                    self.replace(p,self.SingleRightRotation())
                return False 
        if self.key < key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                if not self.right.insertx(self, key):
                    return False 
            if self.balance == "Left":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Right"
                return True
            elif self.balance == "Right":
                if self.right.balance == "Left": 
                    self.replace(p,self.DoubleLeftRotation())
                elif self.right.balance == "Right":
                    self.replace(p,self.SingleLeftRotation())
                return False
        return False 
 
    def to_s(self):
        return self.key
    def left_s(self):
        if self.left == None:
            return None
        return (self.left).key
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).key
        
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(a)]
treeA,treeB = Avltree(),Avltree()
for i in s: treeA.insert(i)
for i in t: treeB.insert(i)
print(1)

import sys
input = sys.stdin.readline
#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return None
        else:
            return search(avl[root][1],key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return None
        else:
            return search(avl[root][2],key)
    return root



def end_lower(root):
    if avl[root][1] == None:
        return avl[root][0]
    else:
        return end_lower(avl[root][1])

def end_higher(root):
    if avl[root][2] == None:
        return avl[root][0]
    else:
        return end_higher(avl[root][2])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_lower(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_lower(avl[root][2],key,lower_key)
    
    # == 
    if avl[root][1] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl[root][1])
        else:
            return max(lower_key,end_higher[root][1])



def search_higher(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_higher(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_higher(avl[root][2],key,higher_key)
    
    # == 
    if avl[root][1] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl[root][1])
        else:
            return min(higher_key,end_lower[root][1])

##search_less(0,x,None):O(logN)

def search_less(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_less(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_less(avl[root][2],key,lower_key)
    
    # == 
    return key

##search_more(0,x,None):O(logN)

def search_more(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_more(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_more(avl[root][2],key,higher_key)
    
    # == 
    return key



def DoubleRightRotation(x):
    tl = avl[x][1]
    avl[x][1] = avl[avl[tl][2]][2]
    avl[avl[tl][2]][2] = x
    tlr = avl[tl][2]
    avl[tl][2] = avl[tlr][1]
    avl[tlr][1] = tl
    if balance[tlr] == -1:
        balance[avl[tlr][2]] = 1
        balance[avl[tlr][1]] = 0
    elif balance[tlr] == 1:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = -1
    else:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl[x][2]
    avl[x][2] = avl[avl[tr][1]][1]
    avl[avl[tr][1]][1] = x
    trl = avl[tl][1]
    avl[tr][1] = avl[trl][2]
    avl[trl][2] = tr
    if balance[trl] == 1:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = -1
    elif balance[trl] == -1:
        balance[avl[trl][1]] = 0
        balance[avl[trl][2]] = 1
    else:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl[x][2]
    balance[tr] = 0
    balance[x] = 0
    avl[x][2] = avl[tr][1]
    avl[tr][1] = x
    return tr

def SingleRightRotaion(x):
    tl = avl[x][1]
    balance[tl] = 0
    balance[x] = 0
    avl[x][1] = avl[tl][2]
    avl[tl][2] = x
    return tl

def replace(x,p,v):
    if avl[p][1] == x:
        avl[p][1] = v
    else:
        avl[p][2] = v

def insertx(root,p,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            avl.append([key,None,None])
            avl[root][1] = len(avl)-1
        else:
            if not insertx(avl[root][1],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl[root][1]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl[root][1]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl[root][0] < key:
        if avl[root][2] == None:
            avl.append([key,None,None])
            avl[root][2] = len(avl)-1
        else:
            if not insertx(avl[root][2],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl[root][2]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl[root][2]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(key):
    if key < avl[0][0]:
        if avl[0][1] == None:
            avl.append([key,None,None])
            avl[0][1] = len(avl)-1
        else:
            insertx(avl[0][1],0,key)
    elif key > avl[0][0]:
        if avl[0][2] == None:
            avl.append([key,None,None])
            avl[0][2] = len(avl)-1
        else:
            insertx(avl[0][2],0,key)
    else:
        pass

########################################################

import sys
input = sys.stdin.readline
a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
#avl[i]:[key,left_index,right_index]
#balance[i]: {"Even":0,"Left":-1,"Right":1}

#N_MAX = 1000000000
avl = [[s[0],None,None]]
balance = [0]*(a)


#avl.append(first_avl)

for i in range(1,a):
    insert(s[i])


t = [int(input()) for i in range(b)]
avl = [[t[0],None,None]]
balance = [0]*(b)
for i in range(1,b):
    insert(t[i])
print(1)

#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return None
        else:
            return search(avl_left[root],key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return None
        else:
            return search(avl_right[root],key)
    return root



def end_lower(root):
    if avl_left[root] == None:
        return avl_key[root]
    else:
        return end_lower(avl_left[root])

def end_higher(root):
    if avl_right[root] == None:
        return avl_key[root]
    else:
        return end_higher(avl_right[root])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return lower_key
        else:
            return search_lower(avl_left[root],key,lower_key)
    if avl_key[root] < key:
        lower_key = avl_key[root]
        if avl_right[root] == None:
            return lower_key
        else:
            return search_lower(avl_right[root],key,lower_key)
    
    # == 
    if avl_left[root] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl_left[root])
        else:
            return max(lower_key,end_higher(avl_left[root]))



def search_higher(root,key,higher_key):
    if avl_key[root] > key:
        higher_key = avl_key[root]
        if avl_left[root] == None:
            return higher_key
        else:
            return search_higher(avl_left[root],key,higher_key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return higher_key
        else:
            return search_higher(avl_right[root],key,higher_key)
    
    # == 
    if avl_right[root] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl_right[root])
        else:
            return min(higher_key,end_lower(avl_right[root]))




def DoubleRightRotation(x):
    tl = avl_left[x]
    avl_left[x] = avl_right[avl_right[tl]]
    avl_right[avl_right[tl]] = x
    tlr = avl_right[tl]
    avl_right[tl] = avl_left[tlr]
    avl_left[tlr] = tl
    if balance[tlr] == -1:
        balance[avl_right[tlr]] = 1
        balance[avl_left[tlr]] = 0
    elif balance[tlr] == 1:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = -1
    else:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl_right[x]
    avl_right[x] = avl_left[avl_left[tr]]
    avl_left[avl_left[tr]] = x
    trl = avl_left[tl]
    avl_left[tr] = avl_right[trl]
    avl_right[trl] = tr
    if balance[trl] == 1:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = -1
    elif balance[trl] == -1:
        balance[avl_left[trl]] = 0
        balance[avl_right[trl]] = 1
    else:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl_right[x]
    balance[tr] = 0
    balance[x] = 0
    avl_right[x] = avl_left[tr]
    avl_left[tr] = x
    return tr

def SingleRightRotaion(x):
    tl = avl_left[x]
    balance[tl] = 0
    balance[x] = 0
    avl_left[x] = avl_right[tl]
    avl_right[tl] = x
    return tl

def replace(x,p,v):
    if avl_left[p] == x:
        avl_left[p] = v
    else:
        avl_right[p] = v

def insertx(root,p,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            if not insertx(avl_left[root],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl_left[root]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl_left[root]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl_key[root] < key:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            if not insertx(avl_right[root],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl_right[root]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl_right[root]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl_key[root]:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            insertx(avl_left[root],root,key)
    elif key > avl_key[root]:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            insertx(avl_right[root],root,key)
    else:
        pass

########################################################



#balance[i]: {"Even":0,"Left":-1,"Right":1}


a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
avl_key = [s[0]]
avl_left = [None]*a
avl_right = [None]*a
balance = [0]*a

for i in range(1,a):
    insert(0,s[i])
t = [int(input()) for i in range(b)]
avl_key = [t[0]]
avl_left = [None]*b
avl_right = [None]*b
balance = [0]*b
for i in range(1,b):
    insert(0,t[i])

print(1)

import sys
 
class Avltree:
    def __init__(self,key=None):
        self.key = key
        self.left = None
        self.right = None 
        self.balance = "Even"
    def search(self,key):
        if self.key == None:
            return None
        if self.key > key:
            if self.left == None:
                return None
            else:
                return self.left.search(key)
        if self.key < key:
            if self.right == None:
                return None
            else:
                return self.right.search(key)
        return self 
        
    def search_lower(self,key,key_lower):
        if self.key == None:
            return key_lower
        if self.key > key:
            if self.left == None:
                return key_lower
            else:
                return self.left.search_lower(key,key_lower)
        if self.key < key:
            key_lower = self.key
            if self.right == None:
                return key_lower
            else:
                return self.right.search_lower(key,key_lower)
        
        if self.left == None:
            return key_lower
        else:
            if key_lower == None:
                return self.left.end_higher(self.left.key)
            else:
                return max(key_lower,self.left.end_higher(self.left.key))
    
    def search_higher(self,key,key_higher):
        if self.key == None:
            return key_higher
        if self.key > key:
            key_higher = self.key
            if self.left == None:
                return key_higher
            else:
                return self.left.search_higher(key,key_higher)
        if self.key < key:
            if self.right == None:
                return key_higher
            else:
                return self.right.search_higher(key,key_higher)
        
        if self.right == None:
            return key_higher
        else:
            if key_higher == None:
                return self.right.end_lower(self.right.key)
            else:
                return min(key_higher,self.right.end_lower(self.right.key))
        
    
    def end_lower(self,end_lower_key):
        if self.left == None:
            return end_lower_key
        else:
            end_lower_key = self.left.key
            return self.left.end_lower(end_lower_key)
    def end_higher(self,end_higher_key):
        if self.right == None:
            return end_higher_key
        else:
            end_higher_key = self.right.key
            return self.right.end_higher(end_higher_key)
    
            
    def DoubleRightRotation(self):
        tl = self.left
        self.left = tl.right.right
        tl.right.right = self 
        tlr = tl.right
        tl.right = tlr.left
        tlr.left = tl
        if tlr.balance == "Left":
            tlr.right.balance = "Right"
            tlr.left.balance = "Even"
        elif tlr.balance == "Right":
            tlr.right.balance = "Even"
            tlr.left.balance = "Left"
        elif tlr.balance == "Even":
            tlr.right.balance = "Even"
            tlr.left.balance = "Even"
        tlr.balance = "Even"
        return tlr
    def DoubleLeftRotation(self):
        tr = self.right
        self.right = tr.left.left
        tr.left.left = self
        trl = tr.left
        tr.left = trl.right
        trl.right = tr
        if trl.balance == "Right":
            trl.left.balance = "Left"
            trl.right.balance = "Even"
        elif trl.balance == "Left":
            trl.left.balance = "Even"
            trl.right.balance = "Right"
        elif trl.balance == "Even":
            trl.left.balance = "Even"
            trl.right.balance = "Even"
        trl.balance = "Even"
        return trl
    def SingleLeftRotation(self):
        tr = self.right
        tr.balance = "Even"
        self.balance = "Even"
        self.right = tr.left
        tr.left = self
        return tr
    def SingleRightRotation(self):
        tl = self.left
        tl.balance = "Even"
        self.balance = "Even"
        self.left = tl.right
        tl.right = self
        return tl
    def replace(self,p,v): 
        if p.left == self:
            p.left = v
        else :
            p.right = v 
    def insert(self,key): 
        if self.key == None: 
            self.key = key
            return self
        if key < self.key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                self.left.insertx(self,key)
        elif key > self.key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                self.right.insertx(self,key)
        else: # key == self.key:
            pass # do not overwrite
    def insertx(self,p,key): 
        if self.key > key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                if not self.left.insertx(self, key): 
                    return False 
            if self.balance == "Right":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Left"
                return True 
            elif self.balance == "Left":
                if self.left.balance == "Right":
                    self.replace(p,self.DoubleRightRotation())
                elif self.left.balance == "Left":
                    self.replace(p,self.SingleRightRotation())
                return False 
        if self.key < key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                if not self.right.insertx(self, key):
                    return False 
            if self.balance == "Left":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Right"
                return True
            elif self.balance == "Right":
                if self.right.balance == "Left": 
                    self.replace(p,self.DoubleLeftRotation())
                elif self.right.balance == "Right":
                    self.replace(p,self.SingleLeftRotation())
                return False
        return False 
 
    def to_s(self):
        return self.key
    def left_s(self):
        if self.left == None:
            return None
        return (self.left).key
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).key
        
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
treeA,treeB = Avltree(),Avltree()
for i in s: treeA.insert(i)
for i in t: treeB.insert(i)
print(1)

import sys
input = sys.stdin.readline
#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return None
        else:
            return search(avl[root][1],key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return None
        else:
            return search(avl[root][2],key)
    return root



def end_lower(root):
    if avl[root][1] == None:
        return avl[root][0]
    else:
        return end_lower(avl[root][1])

def end_higher(root):
    if avl[root][2] == None:
        return avl[root][0]
    else:
        return end_higher(avl[root][2])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_lower(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_lower(avl[root][2],key,lower_key)
    
    # == 
    if avl[root][1] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl[root][1])
        else:
            return max(lower_key,end_higher[root][1])



def search_higher(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_higher(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_higher(avl[root][2],key,higher_key)
    
    # == 
    if avl[root][1] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl[root][1])
        else:
            return min(higher_key,end_lower[root][1])

##search_less(0,x,None):O(logN)

def search_less(root,key,lower_key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            return lower_key
        else:
            return search_less(avl[root][1],key,lower_key)
    if avl[root][0] < key:
        lower_key = avl[root][0]
        if avl[root][2] == None:
            return lower_key
        else:
            return search_less(avl[root][2],key,lower_key)
    
    # == 
    return key

##search_more(0,x,None):O(logN)

def search_more(root,key,higher_key):
    if avl[root][0] > key:
        higher_key = avl[root][0]
        if avl[root][1] == None:
            return higher_key
        else:
            return search_more(avl[root][1],key,higher_key)
    if avl[root][0] < key:
        if avl[root][2] == None:
            return higher_key
        else:
            return search_more(avl[root][2],key,higher_key)
    
    # == 
    return key



def DoubleRightRotation(x):
    tl = avl[x][1]
    avl[x][1] = avl[avl[tl][2]][2]
    avl[avl[tl][2]][2] = x
    tlr = avl[tl][2]
    avl[tl][2] = avl[tlr][1]
    avl[tlr][1] = tl
    if balance[tlr] == -1:
        balance[avl[tlr][2]] = 1
        balance[avl[tlr][1]] = 0
    elif balance[tlr] == 1:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = -1
    else:
        balance[avl[tlr][2]] = 0
        balance[avl[tlr][1]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl[x][2]
    avl[x][2] = avl[avl[tr][1]][1]
    avl[avl[tr][1]][1] = x
    trl = avl[tl][1]
    avl[tr][1] = avl[trl][2]
    avl[trl][2] = tr
    if balance[trl] == 1:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = -1
    elif balance[trl] == -1:
        balance[avl[trl][1]] = 0
        balance[avl[trl][2]] = 1
    else:
        balance[avl[trl][2]] = 0
        balance[avl[trl][1]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl[x][2]
    balance[tr] = 0
    balance[x] = 0
    avl[x][2] = avl[tr][1]
    avl[tr][1] = x
    return tr

def SingleRightRotaion(x):
    tl = avl[x][1]
    balance[tl] = 0
    balance[x] = 0
    avl[x][1] = avl[tl][2]
    avl[tl][2] = x
    return tl

def replace(x,p,v):
    if avl[p][1] == x:
        avl[p][1] = v
    else:
        avl[p][2] = v

def insertx(root,p,key):
    if avl[root][0] > key:
        if avl[root][1] == None:
            avl.append([key,None,None])
            avl[root][1] = len(avl)-1
        else:
            if not insertx(avl[root][1],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl[root][1]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl[root][1]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl[root][0] < key:
        if avl[root][2] == None:
            avl.append([key,None,None])
            avl[root][2] = len(avl)-1
        else:
            if not insertx(avl[root][2],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl[root][2]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl[root][2]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl[root][0]:
        if avl[root][1] == None:
            avl.append([key,None,None])
            avl[root][1] = len(avl)-1
        else:
            insertx(avl[root][1],root,key)
    elif key > avl[root][0]:
        if avl[root][2] == None:
            avl.append([key,None,None])
            avl[root][2] = len(avl)-1
        else:
            insertx(avl[root][2],root,key)
    else:
        pass

########################################################

a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
#avl[i]:[key,left_index,right_index]
#balance[i]: {"Even":0,"Left":-1,"Right":1}

#N_MAX = 1000000000
avl = [[s[0],None,None]]
balance = [0]*(a)


#avl.append(first_avl)

for i in range(1,a):
    insert(0,s[i])
print(1)

class AVLTree(object):
    __slots__ = ["data", "left", "right", "bias", "size", "root"]

    def __init__(self, max_size):
        max_size += 1
        self.data = [0]*max_size
        self.left = [0]*max_size
        self.right = [0]*max_size
        self.bias = [0]*max_size
        self.size = 0
        self.root = 1

    def append_node(self, item):
        self.size += 1
        self.data[self.size] = item
        return self.size

    def __contains__(self, item) -> bool:
        data, left, right = self.data, self.left, self.right
        current = self.root
        while current:
            if data[current] == item:
                return True
            current = left[current] if item < data[current] else right[current]

        return False

    def search_lower(self, item):
        data, left, right = self.data, self.left, self.right
        current, result = self.root, None

        while current:
            if data[current] <= item:
                current, result = right[current], data[current]
            else:
                current = left[current]

        return result

    def search_higher(self, item):
        data, left, right = self.data, self.left, self.right
        current, result = self.root, None

        while current:
            if data[current] >= item:
                current, result = left[current], data[current]
            else:
                current = right[current]

        return result

    def insert(self, item) -> bool:
        left, right, bias, data = self.left, self.right, self.bias, self.data
        if not self.size:
            self.append_node(item)
            return True

        current, bias_delta = self.root, 0
        path = [(self.root, 0)]
        append_path, pop_path = path.append, path.pop

        while True:
            if data[current] == item:
                
                return False
            dest, bias_delta = (left, 1) if data[current] > item else (right, -1)

            if not dest[current]:
                dest[current] = self.append_node(item)
                break
            current = dest[current]
            append_path((current, bias_delta))

        while path:
            current, _delta = pop_path()
            bias[current] += bias_delta
            if not bias[current]:
                
                return True
            bias_delta = _delta

            if bias[current] == 2:
                current = self.rotate(current, left, right, 1, -1)
                break
            elif bias[current] == -2:
                current = self.rotate(current, right, left, -1, 1)
                break

        if path:
            (left if bias_delta > 0 else right)[path[-1][0]] = current
        else:
            self.root = current

        return True

    def rotate(self, parent: int, dir1, dir2, bias_type1, bias_type2) -> int:
        bias = self.bias
        child = dir1[parent]

        if bias[child] == bias_type1:  # case 1
            dir2[child], dir1[parent] = parent, dir2[child]
            bias[parent] = bias[child] = 0
            return child

        # grandchild.left -> child.right, grandchild.right -> parent.left
        grandchild = dir2[child]
        dir2[child], dir1[parent] = dir1[grandchild], dir2[grandchild]
        dir1[grandchild], dir2[grandchild] = child, parent

        if bias[grandchild] == bias_type1:  # case 2
            bias[parent], bias[child], bias[grandchild] = bias_type2, 0, 0
        elif bias[grandchild] == bias_type2:  # case 3
            bias[parent], bias[child], bias[grandchild] = 0, bias_type1, 0
        else:  # case 4
            bias[parent] = bias[child] = 0

        return grandchild

    def print(self):
        def rec(i, depth):
            if self.right[i]:
                rec(self.right[i], depth+1)
            print("{}+---[({}) bias={}]".format(" "*5*depth, self.data[i], self.bias[i]))
            if self.left[i]:
                rec(self.left[i], depth+1)

        rec(self.root, 0)
        print("="*30)


if __name__ == "__main__":
    import sys
    A, B, Q = map(int, input().split())
    minf, inf = -(10**18), 10**18
    jinja_avl, tera_avl = AVLTree(A+2), AVLTree(B+2)
    jinja_insert, tera_insert = jinja_avl.insert, tera_avl.insert

    jsl, jsh = jinja_avl.search_lower, jinja_avl.search_higher
    tsl, tsh = tera_avl.search_lower, tera_avl.search_higher

    jinja_insert(minf)
    jinja_insert(inf)
    tera_insert(minf)
    tera_insert(inf)

    for n in map(int, (sys.stdin.readline() for _ in [0]*A)):
        jinja_insert(n)
    for n in map(int, (sys.stdin.readline() for _ in [0]*B)):
        tera_insert(n)
    ans = []
    append = ans.append

    for q in map(int, sys.stdin):
        left_jinja, right_jinja = q - jsl(q), jsh(q) - q
        left_tera, right_tera = q - tsl(q), tsh(q) - q

        append(min(
            left_jinja if left_jinja > left_tera else left_tera,
            left_jinja + right_tera + (left_jinja if left_jinja < right_tera else right_tera),
            right_jinja + left_tera + (right_jinja if right_jinja < left_tera else left_tera),
            right_jinja if right_jinja > right_tera else right_tera
        ))

    print(1)


import bisect
import sys

class Avltree:
    def __init__(self,key=None):
        self.key = key
        self.left = None
        self.right = None 
        self.balance = "Even"
    def search(self,key):
        if self.key == None:
            return None
        if self.key > key:
            if self.left == None:
                return None
            else:
                return self.left.search(key)
        if self.key < key:
            if self.right == None:
                return None
            else:
                return self.right.search(key)
        return self 
        
    def search_lower(self,key,key_lower):
        if self.key == None:
            return key_lower
        if self.key > key:
            if self.left == None:
                return key_lower
            else:
                return self.left.search_lower(key,key_lower)
        if self.key < key:
            key_lower = self.key
            if self.right == None:
                return key_lower
            else:
                return self.right.search_lower(key,key_lower)
        
        if self.left == None:
            return key_lower
        else:
            if key_lower == None:
                return self.left.end_higher(self.left.key)
            else:
                return max(key_lower,self.left.end_higher(self.left.key))
    
    def search_higher(self,key,key_higher):
        if self.key == None:
            return key_higher
        if self.key > key:
            key_higher = self.key
            if self.left == None:
                return key_higher
            else:
                return self.left.search_higher(key,key_higher)
        if self.key < key:
            if self.right == None:
                return key_higher
            else:
                return self.right.search_higher(key,key_higher)
        
        if self.right == None:
            return key_higher
        else:
            if key_higher == None:
                return self.right.end_lower(self.right.key)
            else:
                return min(key_higher,self.right.end_lower(self.right.key))
        
    
    def end_lower(self,end_lower_key):
        if self.left == None:
            return end_lower_key
        else:
            end_lower_key = self.left.key
            return self.left.end_lower(end_lower_key)
    def end_higher(self,end_higher_key):
        if self.right == None:
            return end_higher_key
        else:
            end_higher_key = self.right.key
            return self.right.end_higher(end_higher_key)
    
            
    def DoubleRightRotation(self):
        tl = self.left
        self.left = tl.right.right
        tl.right.right = self 
        tlr = tl.right
        tl.right = tlr.left
        tlr.left = tl
        if tlr.balance == "Left":
            tlr.right.balance = "Right"
            tlr.left.balance = "Even"
        elif tlr.balance == "Right":
            tlr.right.balance = "Even"
            tlr.left.balance = "Left"
        elif tlr.balance == "Even":
            tlr.right.balance = "Even"
            tlr.left.balance = "Even"
        tlr.balance = "Even"
        return tlr
    def DoubleLeftRotation(self):
        tr = self.right
        self.right = tr.left.left
        tr.left.left = self
        trl = tr.left
        tr.left = trl.right
        trl.right = tr
        if trl.balance == "Right":
            trl.left.balance = "Left"
            trl.right.balance = "Even"
        elif trl.balance == "Left":
            trl.left.balance = "Even"
            trl.right.balance = "Right"
        elif trl.balance == "Even":
            trl.left.balance = "Even"
            trl.right.balance = "Even"
        trl.balance = "Even"
        return trl
    def SingleLeftRotation(self):
        tr = self.right
        tr.balance = "Even"
        self.balance = "Even"
        self.right = tr.left
        tr.left = self
        return tr
    def SingleRightRotation(self):
        tl = self.left
        tl.balance = "Even"
        self.balance = "Even"
        self.left = tl.right
        tl.right = self
        return tl
    def replace(self,p,v): 
        if p.left == self:
            p.left = v
        else :
            p.right = v 
    def insert(self,key): 
        if self.key == None: 
            self.key = key
            return self
        if key < self.key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                self.left.insertx(self,key)
        elif key > self.key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                self.right.insertx(self,key)
        else: # key == self.key:
            pass # do not overwrite
    def insertx(self,p,key): 
        if self.key > key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                if not self.left.insertx(self, key): 
                    return False 
            if self.balance == "Right":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Left"
                return True 
            elif self.balance == "Left":
                if self.left.balance == "Right":
                    self.replace(p,self.DoubleRightRotation())
                elif self.left.balance == "Left":
                    self.replace(p,self.SingleRightRotation())
                return False 
        if self.key < key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                if not self.right.insertx(self, key):
                    return False 
            if self.balance == "Left":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Right"
                return True
            elif self.balance == "Right":
                if self.right.balance == "Left": 
                    self.replace(p,self.DoubleLeftRotation())
                elif self.right.balance == "Right":
                    self.replace(p,self.SingleLeftRotation())
                return False
        return False 

    def to_s(self):
        return self.key
    def left_s(self):
        if self.left == None:
            return None
        return (self.left).key
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).key
        
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]
lens, lent = len(s), len(t)
treeA, treeB = Avltree(), Avltree()
for i in s: treeA.insert(i) 
for i in t: treeB.insert(i)
for i in x:
    # atob
    p1,p2 = 0, 0
    alow = treeA.search_lower(i,10**15)
    ahigh = treeA.search_higher(i,10**15)
    p1 += abs(alow-i)
    p2 += abs(ahigh-i)
    p1 += min(abs(treeB.search_lower(alow,10**15)-alow),abs(treeB.search_higher(alow,10**15)-alow))
    p2 += min(abs(treeB.search_lower(ahigh,10**15)-ahigh),abs(treeB.search_higher(ahigh,10**15)-ahigh))
    ans = min(p1,p2)
    # print(p1,p2)
    
    p3,p4 = 0, 0
    blow = treeB.search_lower(i,10**15)
    bhigh = treeB.search_higher(i,10**15)
    p3 += abs(blow-i)
    p4 += abs(bhigh-i)
    p3 += min(abs(treeA.search_lower(blow,10**15)-blow),abs(treeA.search_higher(blow,10**15)-blow))
    p4 += min(abs(treeA.search_lower(bhigh,10**15)-bhigh),abs(treeA.search_higher(bhigh,10**15)-bhigh))
    ans = min(p3,p4,ans)
    # print(p3,p4)
    print(1)


import sys
class Bintree:
    def __init__(self,data=None): 
        self.data = data
        self.left = None
        self.right = None
    def search(self,data):
        if self.data == None:
            return None
        if data < self.data:
            if self.left == None:
                return None 
            else:
                return self.left.search(data) 
        elif data > self.data:
            if self.right == None:
                return None
            else:
                return self.right.search(data)
        else: 
            return self
    
    def insert(self,data):
        if self.data == None:
            self.data = data
            return self
        if data < self.data:
            if self.left == None:
                self.left = Bintree(data) 
                return True
            else:
                return self.left.insert(data)
        elif data > self.data:
            if self.right == None:
                self.right = Bintree(data)
                return True
            else:
                return self.right.insert(data)
        else: # data == self.data:
            return False
    def to_s(self):
        return self.data
    def left_s(self):
        if self.left==None:
            return None
        return (self.left).data
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).data
 
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]
lens, lent = len(s), len(t)
treeA, treeB = Bintree(), Bintree()
for i in s: treeA.insert(i) 
for i in t: treeB.insert(i)
print(1)

#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return None
        else:
            return search(avl_left[root],key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return None
        else:
            return search(avl_right[root],key)
    return root


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return lower_key
        else:
            return search_lower(avl_left[root],key,lower_key)
    if avl_key[root] < key:
        lower_key = avl_key[root]
        if avl_right[root] == None:
            return lower_key
        else:
            return search_lower(avl_right[root],key,lower_key)
    
    # == 
    return key



def search_higher(root,key,higher_key):
    if avl_key[root] > key:
        higher_key = avl_key[root]
        if avl_left[root] == None:
            return higher_key
        else:
            return search_higher(avl_left[root],key,higher_key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return higher_key
        else:
            return search_higher(avl_right[root],key,higher_key)
    
    # == 
    return key




def DoubleRightRotation(x):
    tl = avl_left[x]
    avl_left[x] = avl_right[avl_right[tl]]
    avl_right[avl_right[tl]] = x
    tlr = avl_right[tl]
    avl_right[tl] = avl_left[tlr]
    avl_left[tlr] = tl
    if balance[tlr] == -1:
        balance[avl_right[tlr]] = 1
        balance[avl_left[tlr]] = 0
    elif balance[tlr] == 1:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = -1
    else:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl_right[x]
    avl_right[x] = avl_left[avl_left[tr]]
    avl_left[avl_left[tr]] = x
    trl = avl_left[tl]
    avl_left[tr] = avl_right[trl]
    avl_right[trl] = tr
    if balance[trl] == 1:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = -1
    elif balance[trl] == -1:
        balance[avl_left[trl]] = 0
        balance[avl_right[trl]] = 1
    else:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl_right[x]
    balance[tr] = 0
    balance[x] = 0
    avl_right[x] = avl_left[tr]
    avl_left[tr] = x
    return tr

def SingleRightRotaion(x):
    tl = avl_left[x]
    balance[tl] = 0
    balance[x] = 0
    avl_left[x] = avl_right[tl]
    avl_right[tl] = x
    return tl

def replace(x,p,v):
    if avl_left[p] == x:
        avl_left[p] = v
    else:
        avl_right[p] = v

def insertx(root,p,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            if not insertx(avl_left[root],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl_left[root]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl_left[root]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl_key[root] < key:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            if not insertx(avl_right[root],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl_right[root]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl_right[root]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl_key[root]:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            insertx(avl_left[root],root,key)
    elif key > avl_key[root]:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            insertx(avl_right[root],root,key)
    else:
        pass

########################################################



#balance[i]: {"Even":0,"Left":-1,"Right":1}


a,b,q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]

avl_key = [s[0]]
avl_left = [None]*(a+2)
avl_right = [None]*(a+2)
balance = [0]*(a+2)
for i in range(1,a):
    insert(0,s[i])
insert(0,float("inf"))
insert(0,-float("inf"))

for i in range(q):
    print(search_higher(0,x[i],None))
    print(search_lower(0,x[i],None))

avl_key = [t[0]]
avl_left = [None]*b
avl_right = [None]*b
balance = [0]*b
insert(0,float("inf"))
insert(0,-float("inf"))
for i in range(1,b):
    insert(0,t[i])
for i in range(q):
    print(search_higher(0,x[i],None))
    print(search_lower(0,x[i],None))


import sys
 
class Avltree:
    def __init__(self,key=None):
        self.key = key
        self.left = None
        self.right = None 
        self.balance = "Even"
    def search(self,key):
        if self.key == None:
            return None
        if self.key > key:
            if self.left == None:
                return None
            else:
                return self.left.search(key)
        if self.key < key:
            if self.right == None:
                return None
            else:
                return self.right.search(key)
        return self 
        
    def search_lower(self,key,key_lower):
        if self.key == None:
            return key_lower
        if self.key > key:
            if self.left == None:
                return key_lower
            else:
                return self.left.search_lower(key,key_lower)
        if self.key < key:
            key_lower = self.key
            if self.right == None:
                return key_lower
            else:
                return self.right.search_lower(key,key_lower)
        
        if self.left == None:
            return key_lower
        else:
            if key_lower == None:
                return self.left.end_higher(self.left.key)
            else:
                return max(key_lower,self.left.end_higher(self.left.key))
    
    def search_higher(self,key,key_higher):
        if self.key == None:
            return key_higher
        if self.key > key:
            key_higher = self.key
            if self.left == None:
                return key_higher
            else:
                return self.left.search_higher(key,key_higher)
        if self.key < key:
            if self.right == None:
                return key_higher
            else:
                return self.right.search_higher(key,key_higher)
        
        if self.right == None:
            return key_higher
        else:
            if key_higher == None:
                return self.right.end_lower(self.right.key)
            else:
                return min(key_higher,self.right.end_lower(self.right.key))
        
    
    def end_lower(self,end_lower_key):
        if self.left == None:
            return end_lower_key
        else:
            end_lower_key = self.left.key
            return self.left.end_lower(end_lower_key)
    def end_higher(self,end_higher_key):
        if self.right == None:
            return end_higher_key
        else:
            end_higher_key = self.right.key
            return self.right.end_higher(end_higher_key)
    
            
    def DoubleRightRotation(self):
        tl = self.left
        self.left = tl.right.right
        tl.right.right = self 
        tlr = tl.right
        tl.right = tlr.left
        tlr.left = tl
        if tlr.balance == "Left":
            tlr.right.balance = "Right"
            tlr.left.balance = "Even"
        elif tlr.balance == "Right":
            tlr.right.balance = "Even"
            tlr.left.balance = "Left"
        elif tlr.balance == "Even":
            tlr.right.balance = "Even"
            tlr.left.balance = "Even"
        tlr.balance = "Even"
        return tlr
    def DoubleLeftRotation(self):
        tr = self.right
        self.right = tr.left.left
        tr.left.left = self
        trl = tr.left
        tr.left = trl.right
        trl.right = tr
        if trl.balance == "Right":
            trl.left.balance = "Left"
            trl.right.balance = "Even"
        elif trl.balance == "Left":
            trl.left.balance = "Even"
            trl.right.balance = "Right"
        elif trl.balance == "Even":
            trl.left.balance = "Even"
            trl.right.balance = "Even"
        trl.balance = "Even"
        return trl
    def SingleLeftRotation(self):
        tr = self.right
        tr.balance = "Even"
        self.balance = "Even"
        self.right = tr.left
        tr.left = self
        return tr
    def SingleRightRotation(self):
        tl = self.left
        tl.balance = "Even"
        self.balance = "Even"
        self.left = tl.right
        tl.right = self
        return tl
    def replace(self,p,v): 
        if p.left == self:
            p.left = v
        else :
            p.right = v 
    def insert(self,key): 
        if self.key == None: 
            self.key = key
            return self
        if key < self.key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                self.left.insertx(self,key)
        elif key > self.key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                self.right.insertx(self,key)
        else: # key == self.key:
            pass # do not overwrite
    def insertx(self,p,key): 
        if self.key > key:
            if self.left == None:
                self.left = Avltree(key)
            else:
                if not self.left.insertx(self, key): 
                    return False 
            if self.balance == "Right":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Left"
                return True 
            elif self.balance == "Left":
                if self.left.balance == "Right":
                    self.replace(p,self.DoubleRightRotation())
                elif self.left.balance == "Left":
                    self.replace(p,self.SingleRightRotation())
                return False 
        if self.key < key:
            if self.right == None:
                self.right = Avltree(key)
            else:
                if not self.right.insertx(self, key):
                    return False 
            if self.balance == "Left":
                self.balance = "Even"
                return False
            elif self.balance == "Even":
                self.balance = "Right"
                return True
            elif self.balance == "Right":
                if self.right.balance == "Left": 
                    self.replace(p,self.DoubleLeftRotation())
                elif self.right.balance == "Right":
                    self.replace(p,self.SingleLeftRotation())
                return False
        return False 
 
    def to_s(self):
        return self.key
    def left_s(self):
        if self.left == None:
            return None
        return (self.left).key
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).key
        
input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
treeA = Avltree()
for i in s: treeA.insert(i)
print(1)

import bisect
import sys
class Bintree:
    def __init__(self,data=None): 
        self.data = data
        self.left = None
        self.right = None
    def search(self,data):
        if self.data == None:
            return None
        if data < self.data:
            if self.left == None:
                return None 
            else:
                return self.left.search(data) 
        elif data > self.data:
            if self.right == None:
                return None
            else:
                return self.right.search(data)
        else: 
            return self
    
    def insert(self,data):
        if self.data == None:
            self.data = data
            return self
        if data < self.data:
            if self.left == None:
                self.left = Bintree(data) 
                return True
            else:
                return self.left.insert(data)
        elif data > self.data:
            if self.right == None:
                self.right = Bintree(data)
                return True
            else:
                return self.right.insert(data)
        else: # data == self.data:
            return False
    def to_s(self):
        return self.data
    def left_s(self):
        if self.left==None:
            return None
        return (self.left).data
    def right_s(self):
        if self.right == None:
            return None
        return (self.right).data

input = sys.stdin.readline
a, b, q = map(int,input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]
lens, lent = len(s), len(t)
treeA, treeB = Bintree(), Bintree()
for i in s: treeA.insert(i) 
for i in t: treeB.insert(i)


#AVL

##search(0,x):O(logN)

def search(root,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return None
        else:
            return search(avl_left[root],key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return None
        else:
            return search(avl_right[root],key)
    return root



def end_lower(root):
    if avl_left[root] == None:
        return avl_key[root]
    else:
        return end_lower(avl_left[root])

def end_higher(root):
    if avl_right[root] == None:
        return avl_key[root]
    else:
        return end_higher(avl_right[root])


##search_lower(0,x,None):O(logN)

def search_lower(root,key,lower_key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            return lower_key
        else:
            return search_lower(avl_left[root],key,lower_key)
    if avl_key[root] < key:
        lower_key = avl_key[root]
        if avl_right[root] == None:
            return lower_key
        else:
            return search_lower(avl_right[root],key,lower_key)
    
    # == 
    if avl_left[root] == None:
        return lower_key
    else:
        if lower_key == None:
            return end_higher(avl_left[root])
        else:
            return max(lower_key,end_higher(avl_left[root]))



def search_higher(root,key,higher_key):
    if avl_key[root] > key:
        higher_key = avl_key[root]
        if avl_left[root] == None:
            return higher_key
        else:
            return search_higher(avl_left[root],key,higher_key)
    if avl_key[root] < key:
        if avl_right[root] == None:
            return higher_key
        else:
            return search_higher(avl_right[root],key,higher_key)
    
    # == 
    if avl_right[root] == None:
        return higher_key
    else:
        if higher_key == None:
            return end_lower(avl_right[root])
        else:
            return min(higher_key,end_lower(avl_right[root]))




def DoubleRightRotation(x):
    tl = avl_left[x]
    avl_left[x] = avl_right[avl_right[tl]]
    avl_right[avl_right[tl]] = x
    tlr = avl_right[tl]
    avl_right[tl] = avl_left[tlr]
    avl_left[tlr] = tl
    if balance[tlr] == -1:
        balance[avl_right[tlr]] = 1
        balance[avl_left[tlr]] = 0
    elif balance[tlr] == 1:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = -1
    else:
        balance[avl_right[tlr]] = 0
        balance[avl_left[tlr]] = 0
    balance[tlr] = 0
    return tlr

def DoubleLeftRotation(x):
    tr = avl_right[x]
    avl_right[x] = avl_left[avl_left[tr]]
    avl_left[avl_left[tr]] = x
    trl = avl_left[tl]
    avl_left[tr] = avl_right[trl]
    avl_right[trl] = tr
    if balance[trl] == 1:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = -1
    elif balance[trl] == -1:
        balance[avl_left[trl]] = 0
        balance[avl_right[trl]] = 1
    else:
        balance[avl_right[trl]] = 0
        balance[avl_left[trl]] = 0
    balance[trl] = 0
    return trl

def SingleLeftRotation(x):
    tr = avl_right[x]
    balance[tr] = 0
    balance[x] = 0
    avl_right[x] = avl_left[tr]
    avl_left[tr] = x
    return tr

def SingleRightRotaion(x):
    tl = avl_left[x]
    balance[tl] = 0
    balance[x] = 0
    avl_left[x] = avl_right[tl]
    avl_right[tl] = x
    return tl

def replace(x,p,v):
    if avl_left[p] == x:
        avl_left[p] = v
    else:
        avl_right[p] = v

def insertx(root,p,key):
    if avl_key[root] > key:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            if not insertx(avl_left[root],root,key):
                return False
        if balance[root] == 1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = -1
            return True
        else:
            if balance[avl_left[root]] == 1:
                replace(root,p,DoubleRightRotation(root))
            elif balance[avl_left[root]] == -1:
                replace(root,p,SingleRightRotation(root))
            return False
    if avl_key[root] < key:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            if not insertx(avl_right[root],root,key):
                return False
        if balance[root] == -1:
            balance[root] = 0
            return False
        elif balance[root] == 0:
            balance[root] = 1
            return True
        else:
            if balance[avl_right[root]] == -1:
                replace(root,p,DoubleLeftRotation(root))
            elif balance[avl_right[root]] == 1:
                replace(root,p,SingleLeftRotation(root))
            return False
    return False


##insert(0,x):O(logN)

def insert(root,key):
    if key < avl_key[root]:
        if avl_left[root] == None:
            avl_key.append(key)
            avl_left[root] = len(avl_key)-1
        else:
            insertx(avl_left[root],root,key)
    elif key > avl_key[root]:
        if avl_right[root] == None:
            avl_key.append(key)
            avl_right[root] = len(avl_key)-1
        else:
            insertx(avl_right[root],root,key)
    else:
        pass

########################################################



#balance[i]: {"Even":0,"Left":-1,"Right":1}


a,b,q = map(int,input().split())
s = int(input())
avl_key = [s]
avl_left = [None]*a
avl_right = [None]*a
balance = [0]*a

for i in range(1,a):
    s = int(input())
    insert(0,s)
t = int(input())
avl_key = [t]
avl_left = [None]*b
avl_right = [None]*b
balance = [0]*b
for i in range(1,b):
    t = int(input())
    insert(0,t)
print(1)


#       )                         .MMdMMM;                    .M#(,dM]                        .:
#       )                        .M@d@d#Mb                    dMGMM(MN                        .:
#       )                        dM1MCdbMM_                  .M@MSN;dM-                       .:
#       )                       .M#(#?d#(Mb.. ...............JMIMIMLdM]                       .:
#       )                      ..M#?NHM# ?MMMMMMMMMH"""""""HMM@(Nad#(Mb                       .:

#       )                ..MMY`     !qN;                       (J     ?MMN,                   .:
#       )               (MMD`       .MM@                      .MM{      .WMN,                 .:
#       )              dM@`         dMM%                      .MM}        (MMm                .:
#       )             .M#`          dMN!                      .MM}        ~(MMr               .:
#       )            .MM:           dM#                       .MM}        ..JM#               .:
#       )      ``    .M@            dMF                       .MM}        .~(M#   `  .        .:

#       )            dMr ?Mm,                                            7YYMM#!`             .:
#       )            dMb   ?`                  .,   ` ..                 ~.(MM%               .:
#       )         ..JgMMNNN)                  .Mn.(Mm-JM{               dHHMMNag.,            .:
#       )         ("!  ?MN,..,                (NM@"`~OMM}             ..~-(M@` _?"M[          .:
#       )               ,MMM#_                .M#    .M#`           .~.~JMMMNg-..             .:

#       )        .gMB=`      _7WMMNaJ...                 ....__-(JJgMMMM^          ?T"^       .:




import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int,input().split())
s = []
t = []
for i in range(a):
    S = int(input())
    s.append(S)
for i in range(b):
    T = int(input())
    t.append(T)
s.sort()
t.sort()

def f(x):
    if 0<=x and a-1>= x:
        return True
    return False
def g(x):
    if 0<=x and b-1>= x:
        return True
    return False
for i in range(q):
    x = int(input())
    p = bisect.bisect_left(s,x)
    m = bisect.bisect_left(t,x)
    
    res = []
    if f(p) and g(m):
        res.append(max(t[m],s[p])-x)
    if f(p) and g(m-1):
        res.append(min(s[p]-x,x-t[m-1])+s[p]-t[m-1])
    if f(p-1) and g(m):
        res.append(t[m]-s[p-1]+min(t[m]-x,x-s[p-1]))
    if f(p-1) and g(m-1):
        res.append(x-min(t[m-1],s[p-1]))
    print(min(res))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted