#include <bits/stdc++.h>
using namespace std;
int parent[2002];
int comp[2002];
int ans[2002];
int fp(int x) {
  if (x == parent[x])
    return x;
  else
    return parent[x] = fp(parent[x]);
}
int main() {
  int n, good, bad;
  cin >> n;
  for (int i = 1; i < n + 1; i++) parent[i] = i;
  cin >> good;
  while (good--) {
    int a, b;
    cin >> a >> b;
    int pa = fp(a), pb = fp(b);
    parent[pa] = parent[pb];
  }
  cin >> bad;
  while (bad--) {
    int a, b;
    cin >> a >> b;
    int pa = fp(a), pb = fp(b);
    if (pa != pb) continue;
    parent[pa] = parent[pb];
    comp[pa] = comp[pb] = 1;
  }
  int maxi = 0;
  for (int i = 1; i < n + 1; i++) {
    int pa = fp(i);
    if (not comp[pa]) ans[pa]++;
    maxi = max(maxi, ans[pa]);
  }
  cout << maxi << endl;
  return 0;
}
