#include <bits/stdc++.h>
using namespace std;
long long fac[2000005] = {0};
void factorial() {
  fac[0] = 1;
  fac[1] = 1;
  for (long long i = 2; i < 200005; i++)
    fac[i] = ((i % 1000000007) * (fac[i - 1] % 1000000007)) % 1000000007;
}
long long power(long long n, long long m) {
  long long p = 1;
  if (m == 0) return 1;
  p = (power(n, m / 2) % 1000000007);
  p = (p % 1000000007 * p % 1000000007) % 1000000007;
  return (m & 1 ? ((p % 1000000007 * n % 1000000007) % 1000000007)
                : (p % 1000000007));
}
long long ncr(long long n, long long r) {
  return ((fac[n] * power(fac[r], 1000000007 - 2)) % 1000000007 *
          power(fac[n - r], 1000000007 - 2)) %
         1000000007;
}
vector<long long> graph[100005];
long long n, m;
long long mx = -1;
set<pair<long long, long long> > s;
vector<long long> v;
long long used[100005];
void dfs(long long t) {
  used[t] = 1;
  v.push_back(t);
  for (auto x : graph[t]) {
    if (!used[x]) dfs(x);
  }
}
void ram5564() {
  cin >> n;
  long long z;
  cin >> z;
  memset(used, 0, sizeof(used));
  for (long long i = 0; i < z; i++) {
    long long x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    s.insert({x, y});
    s.insert({y, x});
  }
  for (long long i = 1; i < n + 1; i++) {
    if (!used[i]) {
      v.clear();
      dfs(i);
      long long ok = 0;
      for (long long j = 0; j < v.size(); j++)
        if (!ok)
          for (long long k = j + 1; k < v.size(); k++)
            if (!ok)
              if (s.count({v[j], v[k]})) ok = 1;
      if (!ok) {
        long long sz = v.size();
        mx = max(mx, sz);
      }
    }
  }
  cout << max(mx, 0ll);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) ram5564();
  return 0;
}
