#include <bits/stdc++.h>
using namespace std;
const long long int LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 9999;
int N, n, m;
vector<int> v1[SIZE], v2[SIZE];
int para[SIZE], parb[SIZE];
pair<int, int> dev[SIZE];
bool vis[SIZE];
struct edge {
  int v, f, c, u;
};
vector<edge> E[SIZE];
int st[SIZE], lvl[SIZE];
void addedge(int a, int b, int ca, int cb) {
  edge A = {a, 0, ca, (int)E[a].size()};
  edge B = {b, 0, cb, (int)E[b].size()};
  E[a].push_back(B);
  E[b].push_back(A);
}
void DFS1(int indx) {
  vis[indx] = true;
  for (int i = 0; i < (int)v1[indx].size(); i++) {
    int idx = v1[indx][i];
    if (vis[idx] == false) {
      addedge(indx, idx + n, 0, 1);
      DFS1(idx);
    }
  }
}
void DFS2(int indx) {
  vis[indx] = true;
  for (int i = 0; i < (int)v2[indx].size(); i++) {
    int idx = v2[indx][i];
    if (vis[idx] == false) {
      addedge(idx + n + n, indx + n + n + m, 0, 1);
      DFS2(idx);
    }
  }
}
void build_graph(int S, int T) {
  for (int i = 1; i <= n; i++) {
    addedge(S, i, 0, INF);
  }
  memset(vis, false, sizeof(vis));
  DFS1(1);
  memset(vis, false, sizeof(vis));
  DFS2(1);
  for (int i = 1; i <= N; i++) {
    int a = dev[i].first;
    while (a != 1) {
      addedge(a + n, i + n + n + m + m, 0, 1);
      a = para[a];
    }
    int b = dev[i].second;
    while (b != 1) {
      addedge(i + n + n + m + m, b + n + n, 0, 1);
      b = parb[b];
    }
  }
  for (int i = 1; i <= m; i++) {
    addedge(i + n + n + m, T, 0, INF);
  }
}
bool BFS(int S, int T) {
  memset(lvl, -1, sizeof(lvl));
  queue<int> q;
  q.push(S);
  lvl[S] = 0;
  while (!q.empty()) {
    int indx = q.front();
    q.pop();
    for (int i = 0; i < (int)E[indx].size(); i++) {
      edge &t = E[indx][i];
      int idx = t.v;
      if (lvl[idx] < 0 && t.c > t.f) {
        lvl[idx] = lvl[indx] + 1;
        q.push(idx);
      }
    }
  }
  return lvl[T] >= 0;
}
int DFS(int indx, int T, int flow) {
  if (indx == T) return flow;
  for (int &i = st[indx]; i < (int)E[indx].size(); i++) {
    edge &t = E[indx][i];
    int idx = t.v;
    if (lvl[idx] == lvl[indx] + 1 && t.c > t.f) {
      int ret = DFS(idx, T, min(flow, t.c - t.f));
      if (ret > 0) {
        t.f += ret;
        E[t.v][t.u].f -= ret;
        return ret;
      }
    }
  }
  return 0;
}
int dinic(int S, int T) {
  int ret = 0;
  while (BFS(S, T)) {
    memset(st, 0, sizeof(st));
    while (int flow = DFS(S, T, INF)) {
      ret += flow;
    }
  }
  return ret;
}
int main() {
  int a, b;
  int S = 0, T = SIZE - 1;
  scanf("%d", &N);
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a);
    v1[i].push_back(a);
    v1[a].push_back(i);
    para[i] = a;
  }
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a);
    dev[i].first = a;
  }
  scanf("%d", &m);
  for (int i = 2; i <= m; i++) {
    scanf("%d", &b);
    v2[i].push_back(b);
    v2[b].push_back(i);
    parb[i] = b;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b);
    dev[i].second = b;
  }
  build_graph(S, T);
  int ans = dinic(S, T);
  ans = (n - 1) + (m - 1) - ans;
  printf("%d\n", ans);
  return 0;
}
