#include <bits/stdc++.h>
using namespace std;
int parent[(long long int)(1e6)], s[(long long int)(1e6)];
int findroot(int x) {
  if (x == parent[x]) return x;
  return parent[x] = findroot(parent[x]);
}
void initial(int n = (long long int)(1e6) - 1) {
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
    s[i] = 1;
  }
}
void make_union(int a, int b) {
  a = findroot(a);
  b = findroot(b);
  if (a != b) {
    if (s[a] < s[b]) swap(a, b);
    parent[b] = a;
    s[a] += s[b];
  }
}
void solve() {
  int n, k, m, ans = 0;
  cin >> n >> k;
  vector<bool> eligible(n + 1, 1);
  initial(n + 1);
  while (k--) {
    int u, v;
    cin >> u >> v;
    make_union(u, v);
  }
  cin >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (findroot(u) == findroot(v)) {
      eligible[parent[u]] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans =
        eligible[findroot(i)] ? (ans > s[parent[i]] ? ans : s[parent[i]]) : ans;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
