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

#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 == (int)v.size() ? "" : " ");
  }
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}
template <typename T, typename U, typename V>
ostream& operator<<(ostream& os, const tuple<T, U, V>& t) {
  os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ')';
  return os;
}
template <typename T, typename U, typename V, typename W>
ostream& operator<<(ostream& os, const tuple<T, U, V, W>& t) {
  os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ','
     << get<3>(t) << ')';
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
  os << '{';
  for (auto itr = m.begin(); itr != m.end();) {
    os << '(' << itr->first << ',' << itr->second << ')';
    if (++itr != m.end()) os << ',';
  }
  os << '}';
  return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const unordered_map<T, U>& m) {
  os << '{';
  for (auto itr = m.begin(); itr != m.end();) {
    os << '(' << itr->first << ',' << itr->second << ')';
    if (++itr != m.end()) os << ',';
  }
  os << '}';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
  os << '{';
  for (auto itr = s.begin(); itr != s.end();) {
    os << *itr;
    if (++itr != s.end()) os << ',';
  }
  os << '}';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& s) {
  os << '{';
  for (auto itr = s.begin(); itr != s.end();) {
    os << *itr;
    if (++itr != s.end()) os << ',';
  }
  os << '}';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& s) {
  os << '{';
  for (auto itr = s.begin(); itr != s.end();) {
    os << *itr;
    if (++itr != s.end()) os << ',';
  }
  os << '}';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const deque<T>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 == (int)v.size() ? "" : " ");
  }
  return os;
}
void debug_out() { cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  cerr << head;
  if (sizeof...(Tail) > 0) cerr << ", ";
  debug_out(move(tail)...);
}
template <typename T>
T gcd(T x, T y) {
  return y != 0 ? gcd(y, x % y) : x;
}
template <typename T>
T lcm(T x, T y) {
  return x / gcd(x, y) * y;
}
template <class T1, class T2>
inline bool chmin(T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T1, class T2>
inline bool chmax(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
map<T, int> compress(vector<T> v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  map<T, int> res;
  for (int i = 0; i < v.size(); i++) res[v[i]] = i;
  return res;
}
const int INF = 1e9;
const long long IINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const char dir[4] = {'D', 'R', 'U', 'L'};
const long long MOD = 1000000007;
template <typename T>
struct RectangleSet {
  const T inf = numeric_limits<T>::max() / 3;
  set<pair<T, T>> s;
  multiset<T> val;
  RectangleSet() {
    s.emplace(-1, inf);
    s.emplace(0, 0);
    val.emplace(0);
  }
  void add(T x, T y) {
    auto itr = s.lower_bound(make_pair(x, y));
    bool flag = false;
    T nx = inf, ny = inf;
    while (1) {
      itr = prev(itr);
      if (y < itr->second) break;
      flag = true;
      nx = min(nx, itr->first);
      ny = min(ny, itr->second);
      val.erase(val.find(itr->first + itr->second));
      s.erase(itr);
    }
    if (flag) {
      s.emplace(nx, y);
      val.emplace(nx + y);
      s.emplace(x, ny);
      val.emplace(x + ny);
    }
  }
  T query() { return *val.begin(); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> a(3, vector<int>(n));
  cin >> a;
  vector<int> val;
  for (auto& v : a) {
    for (int& x : v) {
      val.emplace_back(x);
    }
  }
  map<int, int> mp = compress(val);
  for (auto& v : a) {
    for (int& x : v) {
      x = mp[x];
    }
  }
  int sz = mp.size();
  vector<vector<int>> appear(3, vector<int>(sz, INF));
  for (int i = 0; i < 3; i++) {
    for (int j = n - 1; j >= 0; j--) {
      appear[i][a[i][j]] = j;
    }
  }
  vector<int> cnt(sz, 0);
  for (int& x : a[0]) cnt[x]++;
  RectangleSet<long long> RS;
  for (int i = 0; i < sz; i++) {
    if (!cnt[i]) {
      RS.add(appear[1][i] + 1, appear[2][i] + 1);
    }
  }
  auto erase = [&](int x) {
    int val = a[0][x];
    if (--cnt[val] == 0) RS.add(appear[1][val] + 1, appear[2][val] + 1);
    return true;
  };
  return 0;
}
