#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long T, n, m, k, x, y, z, l, r, d, ans, a[N], b[N], c[N], mod = 1e9 + 7;
int find(int i) { return (a[i] == i ? i : (a[i] = find(a[i]))); }
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) a[i] = i;
  for (long long i = 1; i <= m; i++) cin >> x >> y, a[find(x)] = find(y);
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    if (a[find(x)] == find(y)) b[find(x)] = -1;
  }
  for (int i = 1; i <= n; i++) c[find(i)]++;
  for (int i = 1; i <= n; i++)
    if (b[find(i)] != -1) ans = max(ans, c[find(i)]);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
