#include <bits/stdc++.h>
using namespace std;
long long n, k, m, ans;
vector<long long> e[1000005], v;
set<long long> hate[1000005];
bool mark[1000005];
void dfs(int u) {
  mark[u] = 1;
  v.push_back(u);
  for (int x : e[u]) {
    if (mark[x]) continue;
    dfs(x);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    long long x, y;
    cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    hate[x].insert(y);
    hate[y].insert(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) {
      v.clear();
      dfs(i);
      set<long long> s(v.begin(), v.end());
      bool check = true;
      for (int x : s) {
        for (int y : hate[x]) {
          if (s.count(y)) {
            check = false;
            break;
          }
          if (!check) break;
        }
        if (!check) break;
      }
      if (check) ans = max(ans, (long long)v.size());
    }
  }
  cout << ans;
  return 0;
}
