#include <bits/stdc++.h>
using namespace std;
const long long int N = 5e5 + 10;
const long long int inf = 1e15;
const long long int M = 1e9 + 7;
long long int n, k, m, f[N], cnt[N];
vector<long long int> a[N];
long long int parent[N], ind[N];
long long int find_set(long long int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void make_set(long long int v) {
  parent[v] = v;
  ind[v] = rand();
}
void union_sets(long long int a, long long int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (ind[a] < ind[b]) swap(a, b);
    parent[b] = a;
  }
}
void solve() {
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) {
    make_set(i);
  }
  for (long long int i = 1; i <= k; i++) {
    long long int x, y;
    cin >> x >> y;
    union_sets(x, y);
  }
  cin >> m;
  set<long long int> s;
  for (long long int i = 1; i <= n; i++) {
    s.insert(find_set(i));
    cnt[find_set(i)]++;
  }
  vector<long long int> v(s.size());
  long long int ma = 0;
  for (long long int i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    if (find_set(x) == find_set(y)) f[find_set(x)] = 1;
  }
  for (auto i : s) {
    if (f[i] == 0) {
      ma = max(cnt[i], ma);
    }
  }
  cout << ma;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  long long int x = 0;
  return 0;
}
