#include <bits/stdc++.h>
using namespace std;
int par[2004], siz[2004];
int find_set(int a) {
  if (par[a] == a) return a;
  return par[a] = find_set(par[a]);
}
void union_set(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (siz[a] < siz[b]) swap(a, b);
    par[b] = a;
    siz[a] += siz[b];
  }
}
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  for (int i = 0; i <= 2003; i++) par[i] = i, siz[i] = 1;
  int u, v;
  for (int i = 0; i < k; i++) {
    cin >> u >> v;
    union_set(u, v);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u = find_set(u);
    v = find_set(v);
    if (u == v) {
      siz[u] = -1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int z = find_set(i);
    ans = max(ans, siz[z]);
  }
  cout << ans << "\n";
  return 0;
}
