#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << '\n';
  err(++it, args...);
}
const long long mod = 1e9 + 7;
vector<int> par(20001), sz(20001, 1);
int find(int v) {
  if (v == par[v]) return v;
  return par[v] = find(par[v]);
}
void _union(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    if (sz[a] > sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int k;
  cin >> k;
  iota(par.begin(), par.end(), 0);
  for (__typeof(k) i = (0) - (0 > k); i != (k) - (0 > k);
       i += 1 - 2 * (0 > k)) {
    int x, y;
    cin >> x >> y;
    _union(x, y);
  }
  int m;
  cin >> m;
  for (__typeof(m) i = (0) - (0 > m); i != (m) - (0 > m);
       i += 1 - 2 * (0 > m)) {
    int x, y;
    cin >> x >> y;
    if (find(x) == find(y)) {
      sz[find(x)] = 0;
    }
  }
  int ans = 0;
  for (__typeof(n + 1) i = (1) - (1 > n + 1); i != (n + 1) - (1 > n + 1);
       i += 1 - 2 * (1 > n + 1))
    ans = max(ans, sz[find(i)]);
  cout << ans << '\n';
  return 0;
}
