#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
const int maxn = 1e6 + 6;
const int M = 1e5 + 5;
struct Max_Flow {
  int n, no, dis[N], Q[N], cur[N], head[N];
  struct Edge {
    int s, t, v, net;
    Edge() {}
    Edge(int s, int t, int v, int net) : s(s), t(t), v(v), net(net) {}
  } e[M << 1];
  void init(int _n) {
    n = _n, no = 0;
    memset(head, -1, sizeof(head[0]) * (n + 1));
  }
  void addEdge(int s, int t, int v) {
    e[no] = Edge(s, t, v, head[s]), head[s] = no++;
    e[no] = Edge(t, s, 0, head[t]), head[t] = no++;
  }
  bool bfs(int S, int T) {
    int qh = 0, qt = 0;
    memset(dis, -1, sizeof(dis[0]) * (n + 1));
    dis[S] = 0, Q[qt++] = S;
    while (qh < qt)
      for (int i = head[Q[qh++]]; ~i; i = e[i].net) {
        if (e[i].v && !~dis[e[i].t]) {
          dis[Q[qt++] = e[i].t] = 1 + dis[e[i].s];
          if (e[i].t == T) return 1;
        }
      }
    return 0;
  }
  long long dinic(int S, int T) {
    int u, qt;
    long long maxflow = 0;
    while (bfs(S, T)) {
      memcpy(cur, head, sizeof(cur[0]) * (n + 1));
      u = S, qt = 0;
      while (~cur[S]) {
        if (u == T) {
          long long flow = LINF;
          for (int i = (qt)-1; i >= 0; i--)
            flow = min(flow, (long long)e[Q[i]].v);
          for (int i = (qt)-1; i >= 0; i--) {
            e[Q[i]].v -= flow, e[Q[i] ^ 1].v += flow;
            if (!e[Q[i]].v) qt = i;
          }
          u = e[Q[qt]].s, maxflow += flow;
        } else if (~cur[u] && e[cur[u]].v && dis[u] + 1 == dis[e[cur[u]].t]) {
          Q[qt++] = cur[u];
          u = e[cur[u]].t;
        } else {
          while (u != S && !~cur[u]) u = e[Q[--qt]].s;
          cur[u] = e[cur[u]].net;
        }
      }
    }
    return maxflow;
  }
} T;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  T.init(50005);
  int n, a, b;
  cin >> n;
  cin >> a;
  for (int i = (2); i < (a + 1); i++) {
    int p;
    cin >> p;
    T.addEdge(p, i, INF);
  }
  for (int i = (1); i < (n + 1); i++) {
    int x;
    cin >> x;
    T.addEdge(x, i + a, INF);
  }
  cin >> b;
  for (int i = (2); i < (b + 1); i++) {
    int p;
    cin >> p;
    T.addEdge(i + a + n, p + a + n, INF);
  }
  for (int i = (1); i < (n + 1); i++) {
    int x;
    cin >> x;
    T.addEdge(i + a, n + a + x, INF);
  }
  int S = 0, T1 = 50000;
  for (int i = (2); i < (a + 1); i++) T.addEdge(S, i, 1);
  for (int i = (2); i < (b + 1); i++) T.addEdge(i + a + n, T1, 1);
  cout << a - 1 + b - 1 - T.dinic(S, T1);
  return 0;
}
