#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const long long MAXN = 5003;
namespace FLOW {
long long n, lev[MAXN], ecnt, head[MAXN], cur[MAXN];
struct Graph {
  long long t, cap, flow, nxt;
} G[100005];
void add_edge(long long f, long long t, long long cap) {
  ;
  G[ecnt] = {t, cap, 0, head[f]};
  head[f] = ecnt++;
  G[ecnt] = {f, 0, 0, head[t]};
  head[t] = ecnt++;
}
long long dfs(long long nd, long long t, long long lim) {
  if (nd == t || lim == 0) {
    return lim;
  }
  for (long long &i = cur[nd]; i != -1; i = G[i].nxt) {
    long long x = G[i].t;
    if (G[i].cap > G[i].flow && lev[x] == lev[nd] + 1) {
      long long df = dfs(x, t, min(lim, G[i].cap - G[i].flow));
      if (df) {
        G[i].flow += df;
        G[i ^ 1].flow -= df;
        return df;
      }
    }
  }
  return 0;
}
bool bfs(long long s, long long t) {
  queue<long long> q;
  q.emplace(s);
  memset(lev, -1, sizeof(lev));
  lev[s] = 0;
  while (q.size()) {
    long long nd = q.front();
    q.pop();
    if (nd == t) {
      break;
    }
    for (long long i = head[nd]; i != -1; i = G[i].nxt) {
      if (G[i].cap > G[i].flow && lev[G[i].t] == -1) {
        lev[G[i].t] = lev[nd] + 1;
        q.emplace(G[i].t);
      }
    }
  }
  return lev[t] != -1;
}
long long dinic(long long s, long long t) {
  long long flow = 0;
  ;
  while (bfs(s, t)) {
    long long df = 0;
    for (int i = 0; i < n; i++) {
      cur[i] = head[i];
    }
    while (df = dfs(s, t, INF)) {
      flow += df;
    }
  }
  return flow;
}
void init(int N) {
  n = N;
  memset(head, -1, sizeof(head));
}
};  // namespace FLOW
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  FLOW::init(MAXN);
  cin >> n;
  int s = 0;
  cin >> a;
  for (int i = 2; i <= a; i++) {
    int p;
    cin >> p;
    FLOW::add_edge(0, i + n, 1);
    FLOW::add_edge(p + n, i + n, MOD);
  }
  for (int i = 1; i < (n + 1); i += 1) {
    int x;
    cin >> x;
    FLOW::add_edge(n + x, i, MOD);
  }
  cin >> b;
  int t = n + a + b + 1;
  ;
  for (int i = 2; i <= b; i++) {
    int p;
    cin >> p;
    FLOW::add_edge(i + a + n, t, 1);
    FLOW::add_edge(i + a + n, a + n + p, MOD);
  }
  for (int i = 1; i < (n + 1); i += 1) {
    int x;
    cin >> x;
    FLOW::add_edge(i, n + a + x, MOD);
  };
  cout << (a + b - 2) - FLOW::dinic(s, t) << '\n';
  return 0;
}
