#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
struct BipartiteMatcher {
  vector<vector<int>> G;
  vector<int> L, R, Viz;
  BipartiteMatcher(int n, int m) : G(n), L(n, -1), R(m, -1), Viz(n) {}
  void AddEdge(int a, int b) { G[a].push_back(b); }
  bool Match(int node) {
    if (Viz[node]) return false;
    Viz[node] = true;
    for (auto vec : G[node]) {
      if (R[vec] == -1) {
        L[node] = vec;
        R[vec] = node;
        return true;
      }
    }
    for (auto vec : G[node]) {
      if (Match(R[vec])) {
        L[node] = vec;
        R[vec] = node;
        return true;
      }
    }
    return false;
  }
  int Solve() {
    int ok = true;
    while (ok--) {
      fill(Viz.begin(), Viz.end(), 0);
      for (int i = 0; i < (int)L.size(); ++i)
        if (L[i] == -1) ok |= Match(i);
    }
    int ret = 0;
    for (int i = 0; i < L.size(); ++i) ret += (L[i] != -1);
    return ret;
  }
};
long long int par1[3000];
long long int par2[3000];
vector<long long int> chil1[3000];
vector<long long int> chil2[3000];
long long int x[3000];
long long int y[3000];
set<long long int> used;
void dfs2(long long int u) {
  if (chil1[u].size() == 0) {
    long long int cur = y[x[u]];
    while (cur != 1 && !used.count(cur)) {
      used.insert(cur);
      cur = par2[cur];
    }
  } else {
    for (auto c : chil1[u]) dfs2(c);
  }
}
BipartiteMatcher *match;
void dfs(long long int u) {
  for (auto c : chil1[u]) {
    dfs2(c);
    for (auto a : used) {
      match->AddEdge(c - 2, a - 2);
    }
    used.clear();
    dfs(c);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int a;
  cin >> a;
  par2[1] = -1;
  for (long long int i = 0; i < a - 1; ++i) {
    cin >> par1[i + 2];
    chil1[par1[i + 2]].push_back(i + 2);
  }
  for (long long int i = 0; i < n; ++i) {
    long long int X;
    cin >> X;
    x[X] = i;
  }
  long long int b;
  cin >> b;
  for (long long int i = 0; i < b - 1; ++i) {
    cin >> par2[i + 2];
    chil2[par2[i + 2]].push_back(i + 2);
  }
  for (long long int i = 0; i < n; ++i) {
    cin >> y[i];
  }
  BipartiteMatcher matcha(a - 1, b - 1);
  match = &matcha;
  dfs(1);
  cout << (a - 1 + b - 1) - match->Solve() << endl;
}
