#include <bits/stdc++.h>
using namespace std;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(int &x, int y) {
  if (x > y) x = y;
}
inline int read() {
  char s;
  int k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) k = k * 10 + (s ^ '0'), s = getchar();
  return k * base;
}
inline void write(int x) {
  static char cnt, num[15];
  cnt = 0;
  if (!x) {
    putchar('0');
    return;
  }
  for (; x; x /= 10) num[++cnt] = x % 10;
  for (; cnt; putchar(num[cnt--] + 48))
    ;
}
const int maxn = 2e3 + 100;
int n, m;
int u, v;
int fa[maxn], sz[maxn];
int gf(int x) {
  if (fa[x] == x) return x;
  return fa[x] = gf(fa[x]);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) sz[i] = 1, fa[i] = i;
  m = read();
  while (m--) {
    u = read();
    v = read();
    u = gf(u);
    v = gf(v);
    if (u != v) {
      fa[u] = v;
      sz[v] += sz[u];
      sz[u] = 0;
    }
  }
  m = read();
  while (m--) {
    u = read();
    v = read();
    u = gf(u);
    v = gf(v);
    if (u == v) {
      sz[u] = 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (fa[i] == i) {
      ans = max(ans, sz[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
