There are three arrays a, b and c. Each of them consists of n integers. SmallY wants to find three integers u, v, w (0 ≤ u, v, w ≤ n) such that the following condition holds: each number that appears in the union of a, b and c, appears either in the first u elements of a, or in the first v elements of b, or in the first w elements of c. Of course, SmallY doesn't want to have huge numbers u, v and w, so she wants sum u + v + w to be as small as possible.

Please, help her to find the minimal possible sum of u + v + w.

Input

The first line contains a single integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an — array a. The third line contains the description of array b in the same format. The fourth line contains the description of array c in the same format. The following constraint holds: 1 ≤ ai, bi, ci ≤ 109.

Output

Print a single integer — the minimum possible sum of u + v + w.

Examples

Input

3
1 1 101
1 2 1
3 2 1


Output

5

Input

5
1 1 2 2 3
2 2 4 3 3
3 3 1 1 1


Output

5

Note

In the first example you should choose u = 3, v = 0, w = 2. 

In the second example you should choose u = 1, v = 3, w = 1.
1
2
3
2
 8
190409007 190409007 352375776 190409007 352375776 352375776 352375776 352375776
190409007 190409007 190409007 190409007 190409007 352375776 352375776 190409007
190409007 352375776 352375776 190409007 190409007 190409007 352375776 352375776
 1
1
1
1
 1
377489979
588153796
588153796
 2
1 1
2 2
3 3
 4
1 1 1 1
1 1 1 1
1 1 1 1
 2
1 2
2 2
1 1
 3
1 1 2
1 1 3
1 1 4

2
 2
 1
 2
 3
 1
 2
 9

import fileinput
import copy

i=0
for line in fileinput.input():
    if i==0:
        n = int(line)
        myLists = [[] for i in range(3)]
        i+=1
    else:
        myLists[i-1] = [int(i) for i in line.split()]
        i+=1
#if n == 27:
#    for i in range(len(myLists)):
#        print(myLists[i])

myListsCopy = copy.deepcopy(myLists)
firstL = myListsCopy[0]
secondL = myListsCopy[1]
thirdL = myListsCopy[2]

def sortUnion(listToUnionSort):
    if len(listToUnionSort) ==1:
        ans = list(set(listToUnionSort))
        ans.sort()
        return ans
    else:
        ans = listToUnionSort[0]
        for i in range(1,len(listToUnionSort)):
            ans.extend(listToUnionSort[i])
        ans = list(set(ans))
        ans.sort()
        return ans

class my3Dnode:
    def __init__(self, value):
        self.left = [None,None,None]
        self.right = [None, None, None]
        self.value = value


def StrictG3(node1,node2):
    if node1[0] >= node2[0] and node1[1] >= node2[1] and node1[2] >= node2[2]:
        return True
    else:
        return False


myUnionList = sortUnion(myListsCopy)

L1 = len(myUnionList)
L = len(myLists[0])
myUnionDict = {}

for i in range(L1):
    k = []
    for j in range(3):
        if myUnionList[i] in myLists[j]:
            k.append(myLists[j].index(myUnionList[i]))
        else:
            k.append(L)
    myUnionDict[myUnionList[i]] = k


xyzborder = []


keys = list(myUnionDict.keys())

for i in keys:
    ANY = any([StrictG3(j,myUnionDict[i]) for j in xyzborder])
    if not ANY:
        ALL = [StrictG3(myUnionDict[i],j) for j in xyzborder]
        xyzbordercopy = copy.deepcopy(xyzborder)
        for k in range(len(ALL)):
            if ALL[k]:
                xyzbordercopy.remove(xyzborder[k])
        xyzborder= xyzbordercopy
        xyzborder.append(myUnionDict[i])

rootNode = my3Dnode(xyzborder[0])
startNode = rootNode


for i in range(1, len(xyzborder)):
    node = my3Dnode(xyzborder[i])
    for j in range(3):
        if node.value[j] < rootNode.value[j]:
            currentNode = rootNode
            while node.value[j] < currentNode.value[j]:
                if currentNode.left[j] is None:
                    currentNode.left[j] = node
                    node.right[j] = currentNode
                    if j == 2:
                        startNode = node
                    break
                elif node.value[j] < currentNode.left[j].value[j]:
                    currentNode = currentNode.left[j]

                else:
                    currentNode.left[j].right[j] = node
                    node.left[j] = currentNode.left[j]
                    currentNode.left[j] = node
                    node.right[j] = currentNode
                    break
                
        else:
            currentNode = rootNode
            while node.value[j] >= currentNode.value[j]:
                if currentNode.right[j] is None:
                    currentNode.right[j] = node
                    node.left[j] = currentNode
                    break
                elif node.value[j] >= currentNode.right[j].value[j]:
                    currentNode = currentNode.right[j]
                else:
                    currentNode.right[j].left[j] = node
                    node.right[j] = currentNode.right[j]
                    currentNode.right[j] = node
                    node.left[j] = currentNode
                    break
    
iterator = startNode

ans = 3*n+3
while True:
    
    z = iterator.value[2]
    if iterator.left[0] is not None:
        x = iterator.left[0].value[0]
    else:
        x = -1
    if iterator.left[1] is not None:
        y = iterator.left[1].value[1]
    else:
        y=-1
    if (x+y+z+3<ans):
        ans = x+y+z+3
    
    if iterator.right[2] is None:
        break
    iterator = iterator.right[2]

print(ans)