#include <bits/stdc++.h>
using namespace std;
const int maxN(1e5 + 10);
typedef int i_N[maxN];
int N, M, K;
i_N P, ban;
int get_root(const int u) {
  if (P[u] < 0) return u;
  return P[u] = get_root(P[u]);
}
void join(const int u, const int v) {
  if (P[u] > P[v]) return join(v, u);
  P[u] += P[v];
  P[v] = u;
}
int main() {
  cin >> N;
  cin >> M;
  fill(P + 1, P + N + 1, -1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    const int r1(get_root(x)), r2(get_root(y));
    if (r1 != r2) join(r1, r2);
  }
  cin >> K;
  for (int i = 0; i < K; i++) {
    int x, y;
    cin >> x >> y;
    const int r1(get_root(x)), r2(get_root(y));
    if (r1 == r2) ban[r1] = 1;
  }
  int ans(0);
  for (int u = 1; u <= N; u++)
    if (!ban[u]) ans = max(ans, -P[u]);
  cout << ans;
}
