#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int f[2005], p[2005], T[2005];
int father(int x) {
  if (x != f[x]) {
    f[x] = father(f[x]);
  }
  return f[x];
}
int main() {
  int i, j, l, x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) f[i] = i;
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    int a = father(x);
    int b = father(y);
    if (a == b)
      continue;
    else
      f[b] = a;
  }
  scanf("%d", &k);
  memset(p, 1, sizeof p);
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &x, &y);
    if (father(x) == father(y)) p[father(x)] = -1;
  }
  memset(T, 0, sizeof T);
  for (i = 1; i <= n; i++) T[father(i)]++;
  int ans = 0;
  for (i = 1; i <= n; i++) {
    if (T[i] > ans && p[i] != -1) ans = T[i];
  }
  printf("%d\n", ans);
}
