#include <bits/stdc++.h>
using namespace std;
int N, K;
int A, B;
struct UnionFind {
  int par[2000], ra[2000];
  UnionFind() {
    for (int(i) = 0; (i) < (2000); (i)++) par[i] = i, ra[i] = 1;
  }
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    if ((a = find(a)) != (b = find(b))) {
      if (ra[a] < ra[b]) swap(a, b);
      par[b] = a;
      ra[a] += ra[b];
    }
  }
} uf;
bool cant[2000];
int main() {
  scanf("%d", &N);
  scanf("%d", &K);
  while (K--) scanf("%d%d", &A, &B), uf.unite(A - 1, B - 1);
  scanf("%d", &K);
  while (K--) {
    scanf("%d%d", &A, &B);
    A = uf.find(A - 1), B = uf.find(B - 1);
    if (A == B) uf.ra[A] = 0;
  }
  int res = 0;
  for (int(i) = 0; (i) < (N); (i)++)
    if (uf.find(i) == i) res = max(res, uf.ra[i]);
  printf("%d\n", res);
}
