#include <bits/stdc++.h>
using namespace std;
int f[100100], kl[100100], used[100100], K;
vector<int> g[100100];
void dfs(int v) {
  used[v] = K;
  kl[K]++;
  for (int i = 0; i < g[v].size(); i++)
    if (!used[g[v][i]]) dfs(g[v][i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, k, m;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      K++;
      dfs(i);
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (used[x] == used[y]) f[used[x]] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= K; i++) {
    if (!f[i]) ans = max(ans, kl[i]);
  }
  cout << ans << endl;
  return 0;
}
