#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int n, m;
vector<int> G[maxn];
int color[maxn];
int sz[maxn];
int vis[maxn];
void dfs(int u, int col) {
  color[u] = col;
  for (auto it : G[u]) {
    if (!color[it]) {
      color[it] = col;
      dfs(it, col);
    }
  }
}
int main() {
  cin >> n;
  int x;
  cin >> x;
  for (int i = 1; i <= x; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int tmp = 0;
  for (int i = 1; i <= n; i++) {
    if (!color[i]) {
      dfs(i, ++tmp);
    }
  }
  for (int i = 1; i <= n; i++) sz[color[i]]++;
  int y;
  cin >> y;
  for (int i = 1; i <= y; i++) {
    int u, v;
    cin >> u >> v;
    if (color[u] == color[v]) {
      vis[color[u]] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans = max(ans, sz[i]);
    }
  }
  cout << ans;
  return 0;
}
