#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long modInv(long long a, long long m) {
  a = a % m;
  for (long long x = 1; x < m; x++)
    if ((a * x) % m == 1) return x;
}
long long modinv(long long a, long long m) { return pow(a, m - 2, m); }
const long long N = 10005;
long long n;
vector<long long> g[N];
struct DSU {
  vector<long long> p, sz;
  long long comp;
  void init(long long n) {
    p.resize(n + 1);
    sz.resize(n + 1);
    comp = n;
    for (long long i = 0; i <= n; i++) p[i] = i, sz[i] = 1;
  }
  long long get(long long x) { return (x == p[x] ? x : p[x] = get(p[x])); }
  void unite(long long x, long long y) {
    long long x1 = get(x);
    long long y1 = get(y);
    if (x1 != y1) {
      p[y1] = x1;
      sz[y1] += sz[x1];
      sz[x1] = 0;
      comp--;
    }
  }
  void update_par(long long n) {
    for (long long i = 0; i <= n; i++) {
      p[i] = get(i);
    }
  }
} dsu;
void solve() {
  cin >> n;
  dsu.init(n);
  long long x, y;
  long long m;
  cin >> m;
  while (m--) {
    cin >> x >> y;
    dsu.unite(x, y);
  }
  dsu.update_par(n);
  map<long long, pair<long long, long long> > hash;
  for (long long i = 1; i <= n; ++i) {
    hash[dsu.p[i]].first++;
    hash[dsu.p[i]].second = 1;
  }
  long long o;
  cin >> o;
  while (o--) {
    cin >> x >> y;
    long long x1 = dsu.get(x);
    long long y1 = dsu.get(y);
    if (x1 != y1)
      continue;
    else {
      hash[x1].second = 0;
    }
  }
  long long mx = 0;
  for (auto x : hash) {
    if (x.second.second) {
      mx = max(mx, x.second.first);
    }
  }
  cout << mx;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
