#include <bits/stdc++.h>
using namespace std;
class Set {
 public:
  long long rank;
  long long parent;
};
long long find(Set *set, long long i) {
  if (set[i].parent != i) set[i].parent = find(set, set[i].parent);
  return set[i].parent;
}
void Union(Set *set, long long v1, long long v2) {
  long long v1_root = find(set, v1);
  long long v2_root = find(set, v2);
  if (set[v1_root].rank < set[v2_root].rank) {
    set[v1_root].parent = v2_root;
  } else if (set[v2_root].rank > set[v2_root].rank) {
    set[v2_root].parent = v1_root;
  } else {
    set[v2_root].parent = v1_root;
    set[v1_root].rank++;
  }
}
int main() {
  long long n, k;
  cin >> n >> k;
  Set *set = new Set[n + 1];
  for (long long i = 1; i < n + 1; i++) {
    set[i].parent = i;
    set[i].rank = 0;
  }
  while (k--) {
    long long a, b;
    cin >> a >> b;
    Union(set, a, b);
  }
  long long m;
  cin >> m;
  long long mark[2001] = {0};
  while (m--) {
    long long a, b;
    cin >> a >> b;
    long long p = find(set, a), q = find(set, b);
    if (p == q) mark[p] = 1;
  }
  map<long long, long long> mp;
  for (long long i = 1; i < n + 1; i++) {
    long long q = find(set, i);
    if (mark[q] != 1) mp[q]++;
  }
  long long ans = 0;
  for (auto i : mp) {
    ans = max(ans, i.second);
  }
  cout << ans << "\n";
}
