#include <bits/stdc++.h>
using namespace std;
vector<int> parent;
int find(int u) {
  while (parent[u] != -1) u = parent[u];
  return u;
}
void unionop(int u, int v) {
  int xp = find(u);
  int yp = find(v);
  if (xp != yp) parent[xp] = yp;
}
void solve() {
  int n, k, m, x, y;
  cin >> n;
  parent.resize(n + 1, -1);
  vector<pair<int, int> > p, d;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    p.push_back({x, y});
  }
  for (auto &it : p) {
    unionop(it.first, it.second);
  }
  cin >> m;
  vector<int> count(n + 1, 0);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    int xp = find(x);
    int yp = find(y);
    if (xp == yp) {
      count[xp] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    int par = find(i);
    if (count[par] != -1) {
      count[par]++;
    }
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) mx = max(mx, count[i]);
  cout << mx;
}
int main(void) {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
