#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1},
          ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
const long long MAX = 1e6 + 2047;
const long long mod = 1e9 + 7;
const long long MAX_2 = 1009;
void sout() { cout << "\n"; }
template <typename T, typename... Types>
void sout(T var1, Types... var2) {
  cout << var1 << " ";
  sout(var2...);
}
template <typename T>
void sout(vector<T> arr) {
  for (auto it : arr) {
    cout << it << " ";
  }
  sout();
}
template <typename T>
void sout(set<T> st) {
  for (auto it : st) {
    cout << it << " ";
  }
  sout();
}
vector<long long> parent(1e6 + 10, -1);
vector<long long> conatiner(1e6 + 10, 0);
long long find_set(long long v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void make_set(long long v) {
  parent[v] = v;
  conatiner[v] = 1;
}
void union_sets(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (conatiner[a] < conatiner[b]) swap(a, b);
    parent[b] = a;
    conatiner[a] += conatiner[b];
  }
}
void test_case() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  for (long long i = 1; i <= n; i++) {
    make_set(i);
  }
  for (long long i = 0; i < k; i++) {
    long long u, v;
    cin >> u >> v;
    union_sets(find_set(u), find_set(v));
  }
  map<long long, long long> mp;
  for (long long i = 1; i <= n; i++) {
    long long p = find_set(i);
    mp[p]++;
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    long long x = find_set(u);
    long long y = find_set(v);
    if (x == y) {
      mp[x] = 0;
    }
  }
  long long ans = 0;
  for (auto it : mp) {
    ans = max(ans, it.second);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    test_case();
  }
}
