#include <bits/stdc++.h>
using namespace std;
class dsu {
 public:
  int *id;
  int *compSize;
  int compCount;
  dsu(int N) {
    compCount = N + 1;
    compSize = new int[compCount];
    id = new int[compCount];
    for (int i = 0; i <= compCount; i++) {
      id[i] = i;
      compSize[i] = 1;
    }
  }
  int Find(int p) {
    int root = p;
    while (root != id[root]) root = id[root];
    while (p != root) {
      int newp = id[p];
      id[p] = root;
      p = newp;
    }
    return root;
  }
  bool Connected(int p, int q) { return Find(p) == Find(q); }
  void Union(int p, int q) {
    int i = Find(p);
    int j = Find(q);
    if (i == j) return;
    id[i] = j;
    compSize[j] += compSize[i];
    compCount--;
  }
};
int n, m, p, q, i, sol, rp, rq;
int main() {
  scanf("%d", &n);
  dsu uf(n);
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &p, &q);
    uf.Union(p, q);
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &p, &q);
    rp = uf.Find(p);
    rq = uf.Find(q);
    if (rp == rq) {
      uf.compSize[rp] = 0;
    }
  }
  sol = 0;
  for (i = 1; i <= n; i++) {
    if (i == uf.id[i]) sol = max(sol, uf.compSize[i]);
  }
  printf("%d\n", sol);
  return 0;
}
