#include <bits/stdc++.h>
using namespace std;
struct DS {
  vector<int> p, s;
  void reset(int n) {
    p.resize(n);
    s.resize(n);
    for (int i = 0; i < n; ++i) {
      p[i] = i;
      s[i] = 1;
    }
  }
  int getParent(int v) {
    if (v != p[v]) p[v] = getParent(p[v]);
    return p[v];
  }
  void link(int u, int v) {
    u = getParent(u);
    v = getParent(v);
    if (u == v) return;
    if (s[u] > s[v]) swap(u, v);
    p[u] = v;
    s[v] += s[u];
  }
};
int main() {
  int n;
  cin >> n;
  DS friends;
  friends.reset(n);
  int k;
  cin >> k;
  while (k--) {
    int u, v;
    cin >> u >> v;
    friends.link(u - 1, v - 1);
  }
  vector<bool> ok(n, true);
  cin >> k;
  while (k--) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    if (friends.getParent(u) == friends.getParent(v))
      ok[friends.getParent(u)] = false;
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int p = friends.getParent(i);
    if (ok[p]) res = max(res, friends.s[p]);
  }
  cout << res << endl;
  return 0;
}
