#include <bits/stdc++.h>
using namespace std;
int get_root(int P[], int u) {
  while (u != P[u]) {
    P[u] = P[P[u]];
    u = P[u];
  }
  return u;
}
void union_sets(int P[], int S[], int u, int v) {
  u = get_root(P, u);
  v = get_root(P, v);
  if (u != v) {
    if (S[u] >= S[v]) {
      P[v] = u;
      S[u] += S[v];
    } else {
      P[u] = v;
      S[v] += S[u];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, m, u, v;
  cin >> n;
  int P[n + 1], S[n + 1];
  for (int i = 1; i <= n; i++) {
    P[i] = i;
    S[i] = 1;
  }
  cin >> k;
  for (int i = 1; i <= k; i++) {
    cin >> u >> v;
    union_sets(P, S, u, v);
  }
  cin >> m;
  map<int, bool> F;
  map<int, vector<int>> C;
  for (int i = 1; i <= n; i++) {
    F[get_root(P, i)] = true;
    C[get_root(P, i)].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    if (get_root(P, u) == get_root(P, v)) {
      F[get_root(P, u)] = false;
    }
  }
  int maxf = 0;
  for (auto f : F) {
    if (f.second) {
      if ((int)C[f.first].size() > maxf) maxf = C[f.first].size();
    }
  }
  cout << maxf << endl;
  return 0;
}
