#include <bits/stdc++.h>
int n, m, x, y, k, v[2001], X[200000], Y[200000], p[2001], a[2001][2001], ans;
void dfs(int x, int y) {
  v[x] = y;
  p[y]++;
  for (int i = (1); i <= (n); i++)
    if (a[x][i] && !v[i]) dfs(i, y);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = (1); i <= (k); i++) {
    scanf("%d%d", &x, &y);
    a[x][y] = a[y][x] = 1;
  }
  scanf("%d", &m);
  for (int i = (1); i <= (m); i++) {
    scanf("%d%d", &X[i], &Y[i]);
  }
  for (int i = (1); i <= (n); i++)
    if (!v[i]) dfs(i, i);
  for (int i = (1); i <= (m); i++)
    if (v[X[i]] == v[Y[i]]) p[v[X[i]]] = 0;
  for (int i = (1); i <= (n); i++)
    if (p[i] > ans) ans = p[i];
  printf("%d\n", ans);
}
