#include <bits/stdc++.h>
using namespace std;
const int N = 203600;
int p[N], sz[N];
int n, m;
void init() {
  for (int i = (0); i < (int)(n); i++) p[i] = i, sz[i] = 1;
}
int f(int first) {
  if (first == p[first]) return first;
  return p[first] = f(p[first]);
}
bool gao[N];
int main() {
  while (cin >> n) {
    int m;
    cin >> m;
    init();
    for (int i = (0); i < (int)(m); i++) {
      int first, second;
      cin >> first >> second;
      --first;
      --second;
      int px = f(first), py = f(second);
      if (px ^ py) {
        sz[py] += sz[px];
        sz[px] = 0;
        p[px] = py;
      }
    }
    memset(gao, 0, sizeof(gao));
    cin >> m;
    for (int i = (0); i < (int)(m); i++) {
      int first, second;
      cin >> first >> second;
      --first;
      --second;
      if (f(first) == f(second)) {
        gao[f(first)] = true;
      }
    }
    int ans = 0;
    for (int i = (0); i < (int)(n); i++)
      if (f(i) == i && !gao[i]) {
        ans = max(ans, sz[i]);
      }
    cout << ans << endl;
  }
  return 0;
}
