#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int p[111111];
int s[111111];
int P(int first) {
  return ((p[first] == first) ? (first) : (p[first] = P(p[first])));
}
inline void U(int first, int second) {
  first = P(first);
  second = P(second);
  if (rand() % 2) {
    p[first] = second;
    s[second] += s[first];
  } else {
    p[second] = first;
    s[first] += s[second];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) p[i] = i, s[i] = 1;
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    --first;
    --second;
    if (P(first) != P(second)) U(first, second);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    --first;
    --second;
    if (P(first) == P(second)) s[P(first)] = 0;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (P(i) == i) ans = max(ans, s[i]);
  cout << ans << endl;
}
