#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> friends;
vector<vector<int>> enemies;
vector<int> parent;
int cnt;
bool dfs(int node, int color) {
  parent[node] = color;
  cnt++;
  bool result = true;
  for (int next : friends[node])
    if (parent[next] == 0) result = dfs(next, color) && result;
  for (int next : enemies[node])
    if (parent[next] == color) result = false;
  return result;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  friends.resize(n);
  enemies.resize(n);
  parent.resize(n, 0);
  int m, a, b;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    enemies[a].push_back(b);
    enemies[b].push_back(a);
  }
  int result = 0, color = 0;
  for (int i = 0; i < n; ++i)
    if (parent[i] == 0) {
      cnt = 0;
      if (dfs(i, ++color)) {
        result = max(result, cnt);
      }
    }
  cout << result << endl;
  return 0;
}
