#include <bits/stdc++.h>
using namespace std;
long long n, k, m;
vector<vector<long long> > friends, enemies;
vector<long long> group_nums;
vector<bool> visited;
long long dfs(long long node, bool &ok, long long num) {
  long long cnt = 1;
  visited[node] = true;
  group_nums[node] = num;
  for (auto neigh : friends[node]) {
    if (!visited[neigh]) {
      cnt += dfs(neigh, ok, num);
    }
  }
  for (auto e : enemies[node]) {
    if (group_nums[e] == group_nums[node]) {
      ok = false;
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n;
  friends.resize(n + 1);
  enemies.resize(n + 1);
  cin >> k;
  for (long long i = 0; i < k; ++i) {
    long long a, b;
    cin >> a >> b;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    enemies[a].push_back(b);
    enemies[b].push_back(a);
  }
  group_nums.resize(n + 1, -1);
  visited.resize(n + 1, false);
  long long ans = 0, num = 1;
  for (long long i = 1; i <= n; ++i) {
    if (!visited[i]) {
      bool ok = true;
      long long val = dfs(i, ok, num++);
      if (ok) {
        ans = max(ans, val);
      }
    }
  }
  cout << ans;
  return 0;
}
