#include <bits/stdc++.h>
using namespace std;
void fun() {}
const long long int N = 2007;
std::vector<long long int> v[N];
bool visited[N];
std::vector<long long int> friends;
long long int enemy[N][N];
void dfs(long long int node) {
  visited[node] = true;
  for (auto to : v[node]) {
    if (!visited[to]) {
      dfs(to);
    }
  }
  friends.push_back(node);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  fun();
  long long int tests = 1;
  while (tests--) {
    long long int n;
    cin >> n;
    long long int m;
    cin >> m;
    for (long long int i = 1; i <= m; i++) {
      long long int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      v[y].push_back(x);
    }
    cin >> m;
    for (long long int i = 1; i <= m; i++) {
      long long int x, y;
      cin >> x >> y;
      enemy[x][y] = 1;
      enemy[y][x] = 1;
    }
    long long int maxInvitations = 0;
    for (long long int i = 1; i <= n; i++) {
      if (!visited[i]) {
        friends.clear();
        dfs(i);
        bool stillFriends = true;
        for (long long int j = 0; j < friends.size(); j++) {
          for (long long int k = 0; k < friends.size(); k++) {
            if (enemy[friends[j]][friends[k]]) {
              stillFriends &= false;
            }
          }
        }
        if (stillFriends) {
          maxInvitations = max(maxInvitations, (long long int)friends.size());
        }
      }
    }
    cout << maxInvitations;
  }
  cerr << "time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}
