#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 100;
int fa[N];
int Find(int x) { return fa[x] < 0 ? x : fa[x] = Find(fa[x]); }
void Union(int x, int y) {
  int rx = Find(x);
  int ry = Find(y);
  if (rx != ry) {
    fa[rx] += fa[ry];
    fa[ry] = rx;
  }
}
int main() {
  int n;
  scanf("%d", &(n));
  memset((fa), -1, sizeof(fa));
  int m;
  scanf("%d", &(m));
  while (m--) {
    int x, y;
    scanf("%d", &(x)), scanf("%d", &(y));
    Union(x, y);
  }
  int k;
  scanf("%d", &(k));
  int cant[N];
  memset((cant), 0, sizeof(cant));
  while (k--) {
    int x, y;
    scanf("%d", &(x)), scanf("%d", &(y));
    if (Find(x) == Find(y)) cant[Find(x)] = 1;
  }
  int ans = 0;
  for (int i(1), _h(n); i <= _h; ++i)
    if (Find(i) == i) {
      if (!cant[i] && -fa[i] > ans) ans = -fa[i];
    }
  printf("%d\n", (ans));
  return 0;
}
