#include <bits/stdc++.h>
template <class T>
T gcd(T a, T b) {
  while (b) b ^= a ^= b ^= a %= b;
  return (a);
}
template <class T>
T lcm(T a, T b) {
  return (a * b / gcd(a, b));
}
using namespace std;
vector<vector<int> > g(2001), p(2001);
bool used[2001];
int ans, use = 0;
void dfs(int x) {
  used[x] = 1;
  for (int i = 0; i < (int)g[x].size(); i++)
    if (!used[g[x][i]]) dfs(g[x][i]);
}
int main() {
  int n, m, k, x, y, i, j, c, cur;
  bool good;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    p[x].push_back(y);
    p[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; used[j++] = 0)
      ;
    dfs(i);
    good = 1, cur = 0;
    for (j = 1; j <= n && good; j++)
      if (used[j]) {
        cur++;
        for (c = 0; c < ((p[j]).size()); c++)
          if (used[p[j][c]]) {
            good = false;
            break;
          }
      }
    if (good) ans = max(ans, cur);
  }
  cout << ans;
  return 0;
}
