#include <bits/stdc++.h>
using namespace std;
int p[120000], size[120000], br[120000], is[120000];
void make(int x) {
  size[x] = 1;
  p[x] = x;
}
int find(int x) {
  if (x == p[x]) return x;
  return p[x] = find(p[x]);
}
void uni(int x, int y) {
  x = find(x);
  y = find(y);
  if (x != y) {
    if (x < y) swap(x, y);
    p[y] = x;
    size[x] += size[y];
  }
}
int main() {
  int x, y, n, m, k, i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) make(i);
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    uni(x, y);
  }
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    x--;
    y--;
    j = find(x);
    if (j == find(y)) br[j] = 1;
  }
  int mx = 0;
  for (i = 0; i < n; i++) {
    j = find(i);
    is[j] = 1;
  }
  for (i = 0; i < n; i++)
    if (size[i] > mx && br[i] == 0 && is[i]) {
      mx = size[i];
    }
  cout << mx << endl;
  return 0;
}
