#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9, MOD = 998244353;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long power(long long a, long long b) {
  return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1));
}
long long mod(long long a) { return (a % MOD + MOD) % MOD; }
const long long N = 2e3 + 20;
long long par[N];
long long sz[N];
long long getPar(long long v) {
  return (par[v] == v ? v : par[v] = getPar(par[v]));
}
void merge(long long v, long long u) {
  v = getPar(v);
  u = getPar(u);
  if (v == u) return;
  if (sz[v] > sz[u]) swap(v, u);
  par[v] = u;
  sz[u] += sz[v];
  sz[v] = 0;
}
void unmerge(long long v, long long u) {
  v = getPar(v);
  u = getPar(u);
  if (v != u) return;
  sz[v] = sz[u] = 0;
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) par[i] = i, sz[i] = 1;
  long long k;
  cin >> k;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    merge(x, y);
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    unmerge(x, y);
  }
  long long mx = 0;
  for (long long i = 1; i <= n; i++) mx = max(mx, sz[getPar(i)]);
  cout << mx << "\n";
  return 0;
}
