#include <bits/stdc++.h>
using namespace std;
const long long N = 2005;
vector<long long> adj[N];
bool cant[N];
long long numcomp, comp[N], cursz, friends[N];
void dfs(long long v) {
  comp[v] = numcomp;
  cursz++;
  for (auto &u : adj[v])
    if (!comp[u]) dfs(u);
  return;
}
int main() {
  long long n, k, i, v, u, m, ans;
  cin >> n >> k;
  for (i = 1; i <= k; i++) {
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  numcomp = 0;
  for (i = 1; i <= n; i++) {
    if (!comp[i]) {
      numcomp++;
      cursz = 0;
      dfs(i);
      friends[numcomp] = cursz;
    }
  }
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> v >> u;
    if (comp[v] == comp[u]) cant[comp[v]] = true;
  }
  ans = 0;
  for (i = 1; i <= numcomp; i++) {
    if (!cant[i]) ans = max(ans, friends[i]);
  }
  cout << ans << "\n";
  return 0;
}
