#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > g(2005);
vector<vector<long long int> > hate(2005, vector<long long int>(2005));
vector<bool> used(2005);
vector<long long int> ans;
void dfs(long long int v) {
  used[v] = true;
  ans.push_back(v);
  for (auto i : g[v]) {
    if (!used[i]) dfs(i);
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long int n, f;
  cin >> n >> f;
  for (long long int i = 0; i < f; ++i) {
    long long int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  long long int h;
  cin >> h;
  for (long long int i = 0; i < h; ++i) {
    long long int a, b;
    cin >> a >> b;
    hate[a][b] = 1;
  }
  long long int answer = 0;
  for (long long int i = 1; i <= n; ++i) {
    ans.clear();
    bool ok = 1;
    if (!used[i]) {
      dfs(i);
      for (auto g : ans) {
        for (auto j : ans) {
          if (hate[g][j]) {
            ok = 0;
            break;
          }
        }
      }
      if (ok) {
        if (ans.size() > answer) answer = ans.size();
      }
    }
  }
  cout << answer;
  return 0;
}
