#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 4;
vector<vector<int> > G(N);
vector<int> par(N);
vector<bool> vis(N);
map<int, int> MP;
int cnt;
void dfs(int root, int u) {
  vis[root] = true;
  cnt++;
  par[root] = u;
  for (int i = 0; i < G[root].size(); i++) {
    int v = G[root][i];
    if (!vis[v]) dfs(v, u);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b), G[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt = 0;
      dfs(i, i);
      MP[i] = cnt;
    }
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (par[u] == par[v]) MP[par[u]] = 0;
  }
  int mx = 0;
  map<int, int>::iterator it;
  for (it = MP.begin(); it != MP.end(); it++) mx = max(mx, it->second);
  cout << mx << '\n';
  return 0;
}
