#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const int inf = 1 << 29;
const double eps = 1e-8;
int par[maxn], siz[maxn];
bool vis[maxn];
int findset(int x) {
  if (par[x] != x) par[x] = findset(par[x]);
  return par[x];
}
void unionset(int x, int y) {
  int fx = findset(x);
  int fy = findset(y);
  if (fx == fy)
    return;
  else {
    par[fx] = fy;
    siz[fy] += siz[fx];
  }
}
int main() {
  int n, k, m, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    siz[i] = 1;
  }
  scanf("%d", &k);
  while (k--) {
    int a, b;
    scanf("%d%d", &a, &b);
    unionset(a, b);
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    if (findset(a) == findset(b)) {
      vis[findset(a)] = 1;
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (par[i] == i && !vis[i]) {
      res = max(res, siz[i]);
    }
  }
  printf("%d\n", res);
}
