#include <bits/stdc++.h>
using namespace std;
const int maxn = 20010;
int father[maxn];
bool Not[maxn];
int cnt[maxn];
void init() {
  for (int i = 0; i < maxn; ++i) father[i] = i;
  memset(Not, false, sizeof(Not));
  memset(cnt, 0, sizeof(cnt));
}
int find(int x) {
  if (father[x] != x) father[x] = find(father[x]);
  return father[x];
}
void Union(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  father[a] = b;
}
int main() {
  int n, k, m;
  int u, v;
  while (scanf("%d", &n) != EOF) {
    init();
    scanf("%d", &k);
    for (int i = 0; i < k; ++i) {
      scanf("%d %d", &u, &v);
      Union(u, v);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
      scanf("%d %d", &u, &v);
      if (find(u) == find(v)) {
        Not[find(u)] = true;
      }
    }
    int ret = 0;
    for (int i = 1; i <= n; ++i) {
      if (!Not[find(i)]) cnt[find(i)]++;
    }
    for (int i = 1; i <= n; ++i) ret = max(ret, cnt[i]);
    printf("%d\n", ret);
  }
  return 0;
}
