#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
static int comp[maxn];
static int pr[maxn];
static int n;
void make_set() {
  for (int i = 0; i < n; ++i) {
    pr[i] = i;
    comp[i] = 1;
  }
}
int find_set(int a) {
  if (pr[a] == a) return a;
  return pr[a] = find_set(pr[a]);
}
void union_set(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  pr[a] = b;
  comp[b] += comp[a];
  comp[a] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  int m;
  cin >> m;
  make_set();
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (find_set(a) != find_set(b)) union_set(a, b);
  }
  int k;
  cin >> k;
  for (int j = 0; j < k; ++j) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (find_set(a) == find_set(b)) {
      comp[find_set(a)] = 0;
    }
  }
  int mx = 0;
  for (int l = 0; l < n; ++l) {
    mx = max(mx, comp[l]);
  }
  cout << mx;
}
