#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, e1, e2;
int par[2010], ch[2010];
int ans = 0;
int get_par(int x) { return par[x] == x ? x : par[x] = get_par(par[x]); }
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    ch[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    x = get_par(x), y = get_par(y);
    if (x != y) {
      par[y] = x;
      ch[x] += ch[y];
    }
  }
  cin >> k;
  for (int i = 1; i <= k; i++) {
    cin >> x >> y;
    x = get_par(x), y = get_par(y);
    if (x == y) ch[x] = 0;
  }
  for (int i = 1; i <= n; i++)
    if (get_par(i) == i && ans < ch[i]) ans = ch[i];
  cout << ans << endl;
  return 0;
}
