#include <bits/stdc++.h>
using namespace std;
int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
bool vis[2005], ver;
int cnt, j;
vector<int> e;
void dfs(vector<pair<int, int> > g[], int t) {
  vis[t] = true;
  cnt++;
  for (int i = 0; i < g[t].size(); i++) {
    if (g[t][i].second == 1) {
      if (vis[g[t][i].first] == false) {
        for (j = 0; j < e.size(); j++) {
          if (e[j] == g[t][i].first) break;
        }
        if (j == e.size())
          dfs(g, g[t][i].first);
        else {
          ver = false;
          return;
        }
      }
    } else {
      if (vis[g[t][i].first] == false)
        e.push_back(g[t][i].first);
      else {
        ver = false;
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, m, i, ans = 0;
  cin >> n >> k;
  vector<pair<int, int> > g[2005];
  for (i = 1; i <= k; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back({v, 1});
    g[v].push_back({u, 1});
  }
  cin >> m;
  for (i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back({v, 0});
    g[v].push_back({u, 0});
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= n; j++) vis[j] = false;
    cnt = 0;
    ver = true;
    dfs(g, i);
    if (ver == true) ans = max(ans, cnt);
    e.clear();
  }
  cout << ans;
  return 0;
}
