#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e4 + 100;
int root[MAXN], sz[MAXN];
bool mark[MAXN];
int get_root(int u) { return (root[u] ? root[u] = get_root(root[u]) : u); }
void merge(int u, int v) {
  int ru = get_root(u);
  int rv = get_root(v);
  if (rv == ru) return;
  root[ru] = rv;
  sz[rv] += sz[ru];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, m, x, y;
  cin >> n >> k;
  fill(sz + 1, sz + n + 1, 1);
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    merge(x, y);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (get_root(x) == get_root(y)) mark[get_root(y)] = true;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int r = get_root(i);
    if (mark[r]) continue;
    ans = max(ans, sz[r]);
    mark[r] = true;
  }
  cout << ans << endl;
  return 0;
}
