#include <bits/stdc++.h>
using namespace std;
void fun() {}
long long mod = 1000000000 + 7;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
long long par[20001], s[20001];
void init(long long n) {
  for (long long i = 1; i <= n; i++) {
    par[i] = i;
    s[i] = 1;
  }
}
long long root(long long x) {
  while (par[x] != x) {
    par[x] = par[par[x]];
    x = par[x];
  }
  return x;
}
void join(long long x, long long y) {
  long long r1 = root(x);
  long long r2 = root(y);
  if (r1 != r2) {
    if (s[r1] > s[r2]) swap(r1, r2);
    par[r1] = r2;
    s[r2] += s[r1];
  }
}
void find(long long x, long long y) {
  long long r1 = root(x);
  long long r2 = root(y);
  if (r1 == r2) s[r1] = 0;
}
int32_t main() {
  fun();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, i, j, x, y, sum = 0, num1, num2, d, ans = 0, k;
  cin >> n;
  cin >> k;
  init(n);
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    join(x, y);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    find(x, y);
  }
  for (i = 1; i <= n; i++) {
    if (s[i] > 0 && s[root(i)] != 0) ans = max(s[i], ans);
  }
  cout << ans;
}
