#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 123, MAXN = 2e5 + 47, MEGAINF = 1e18;
template <class T>
istream& operator>>(istream& in, vector<T>& a) {
  for (auto& i : a) in >> i;
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& a) {
  for (auto& i : a) out << i << " ";
  return out;
}
template <class T, class U>
istream& operator>>(istream& in, vector<pair<T, U>>& a) {
  for (auto& i : a) in >> i.first >> i.second;
  return in;
}
template <class T, class U>
ostream& operator<<(ostream& out, vector<pair<T, U>>& a) {
  for (auto& i : a) out << i.first << " " << i.second << endl;
  return out;
}
vector<long long> par, sz;
void make(long long v) {
  par[v] = v;
  sz[v] = 1;
}
long long find(long long v) {
  if (v == par[v]) return v;
  return par[v] = find(par[v]);
}
void unite(long long a, long long b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (sz[a] < sz[b]) swap(a, b);
  par[b] = a;
  sz[a] += sz[b];
}
signed main() {
  setlocale(LC_ALL, "rus");
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  par.resize(n);
  sz.resize(n);
  for (long long i = 0; i < n; ++i) make(i);
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    unite(u, v);
  }
  cin >> m;
  vector<long long> used(n);
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    u = find(u);
    v = find(v);
    if (u == v) used[u] = 1;
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long comp = find(i);
    if (!used[comp]) ans = max(ans, sz[comp]);
  }
  cout << ans;
}
