#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> v(100002);
vector<int> vis(100002);
vector<int> dfs(int src) {
  stack<int> st;
  st.push(src);
  vector<int> sts;
  vis[src] = 1;
  sts.push_back(src);
  while (!st.empty()) {
    int x = st.top();
    st.pop();
    if (!vis[x]) {
      sts.push_back(x);
      vis[x] = 1;
    }
    for (int i = 0; i < v[x].size(); i++) {
      if (vis[v[x][i]] == 0) st.push(v[x][i]);
    }
  }
  return sts;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  fill(vis.begin(), vis.end(), 0);
  for (int i = 0; i < v.size(); i++) v[i].clear();
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  vector<vector<int>> dis(1000005);
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    dis[a].push_back(b);
    dis[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vector<int> tr = dfs(i);
      sort(tr.begin(), tr.end());
      int f = 0;
      for (int i = 0; i < tr.size(); i++) {
        for (int j = 0; j < dis[tr[i]].size(); j++) {
          if (dis[tr[i]][j] != 0) {
            int disx = dis[tr[i]][j];
            if (binary_search(tr.begin(), tr.end(), disx)) {
              f = 1;
              break;
            }
          }
        }
      }
      if (f == 0) {
        int xx = tr.size();
        ans = max(ans, xx);
      }
    }
  }
  cout << ans << endl;
}
