Problem: 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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MXN = 300010, inf = ~0U >> 2;
int N;
int A[3][MXN];
int sa[MXN], n = 0;
struct tri {
  int c[3];
};
bool cmp(const tri& a, const tri& b) { return a.c[0] > b.c[0]; }
tri th[MXN];
void init() {
  scanf("%d", &N);
  for (int k = 0; k < 3; k++)
    for (int i = 1; i <= N; i++) scanf("%d", &A[k][i]), sa[++n] = A[k][i];
  sort(sa + 1, sa + n + 1);
  n = unique(sa + 1, sa + n + 1) - sa - 1;
  for (int i = 1; i <= n; i++)
    for (int k = 0; k < 3; k++) th[i].c[k] = N * 3;
  for (int k = 0; k < 3; k++)
    for (int i = 1; i <= N; i++) {
      static int x;
      A[k][i] = x = lower_bound(sa + 1, sa + n + 1, A[k][i]) - sa;
      th[x].c[k] = min(th[x].c[k], i);
    }
}
namespace solve {
set<pair<int, int> > S;
multiset<int> Q;
int answer = inf;
void hi(int x, int y) { Q.insert(x + y); }
void bye(int x, int y) { Q.erase(Q.find(x + y)); }
void ins(int x, int y) {
  set<pair<int, int> >::iterator s = S.lower_bound(pair<int, int>(x, y));
  if (s->second >= y) return;
  set<pair<int, int> >::iterator p = s, q = p--;
  bye(p->first, q->second);
  while (p->second <= y) {
    if (p == S.begin()) {
      cout << "ERROR" << endl;
      return;
    }
    q = p--;
    bye(p->first, q->second);
    S.erase(q);
  }
  S.insert(pair<int, int>(x, y));
  hi(p->first, y);
  hi(x, s->second);
}
void solve() {
  sort(th + 1, th + n + 1, cmp);
  S.insert(pair<int, int>(0, inf));
  S.insert(pair<int, int>(inf, 0));
  hi(0, 0);
  for (int i = 1; i <= n; i++) {
    answer = min(answer, th[i].c[0] + *Q.begin());
    int j = i;
    while (j < n && th[j].c[0] == th[j + 1].c[0]) j++;
    for (int k = i; k <= j; k++) ins(th[k].c[1], th[k].c[2]);
    i = j;
  }
  answer = min(answer, *Q.begin());
  printf("%d\n", answer);
}
}  // namespace solve
int main() {
  init();
  solve::solve();
  return 0;
}