#include <bits/stdc++.h>
using namespace std;
int fa[10000];
int num[10000];
int i, j, n, k;
int find(int u) { return (u == fa[u]) ? u : fa[u] = find(fa[u]); }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) fa[i] = i;
  scanf("%d", &k);
  for (i = 1; i <= k; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    fa[find(u)] = find(v);
  }
  scanf("%d", &k);
  for (i = 1; i <= k; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    int f1 = find(u), f2 = find(v);
    if (f1 == f2) num[f1] = -1;
  }
  for (i = 1; i <= n; i++) {
    int f = find(i);
    if (num[f] != -1) num[f]++;
  }
  int maxx = 0;
  for (i = 1; i <= n; i++) {
    int f = find(i);
    if (num[f] > maxx) maxx = num[f];
  }
  printf("%d\n", maxx);
  return 0;
}
