#include <bits/stdc++.h>
using namespace std;
int p[2010], sz[2010];
int root(int x) { return p[x] != x ? p[x] = root(p[x]) : x; }
void join(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] >= sz[y])
    sz[p[y] = x] += sz[y];
  else
    sz[p[x] = y] += sz[x];
}
int main() {
  int n, k, m;
  scanf("%d%d", &n, &k);
  for (int(i) = 0; (i) < (int)(n); ++(i)) sz[p[i] = i] = 1;
  for (int(i) = 0; (i) < (int)(k); ++(i)) {
    int x, y;
    scanf("%d%d", &x, &y);
    join(x - 1, y - 1);
  }
  scanf("%d", &m);
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (root(--x) == root(--y)) sz[root(x)] = 0;
  }
  int ans = -1;
  for (int(i) = 0; (i) < (int)(n); ++(i)) ans = max(ans, sz[root(i)]);
  printf("%d\n", ans);
}
