#include <bits/stdc++.h>
int n, k, m, lk[2100], c[2100], nc, sz[2100];
int r[2 * 110000], nxt[2 * 110000], nr;
int stk[2100], top;
int dfs(int x, int cx) {
  int cnt = 0;
  top = -1;
  c[x] = cx;
  ++cnt;
  stk[++top] = x;
  while (top >= 0) {
    int x = stk[top--];
    for (int i = lk[x]; i >= 0; i = nxt[i])
      if (!c[r[i]]) {
        c[r[i]] = cx;
        ++cnt;
        stk[++top] = r[i];
      }
  }
  return cnt;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    lk[i] = -1;
    c[i] = 0;
  }
  nr = 0;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    r[nr] = y;
    nxt[nr] = lk[x];
    lk[x] = nr++;
    r[nr] = x;
    nxt[nr] = lk[y];
    lk[y] = nr++;
  }
  nc = 0;
  for (int i = 1; i <= n; i++)
    if (!c[i]) {
      int ret = dfs(i, ++nc);
      sz[nc] = ret;
    }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (c[x] == c[y]) {
      sz[c[x]] = 0;
    }
  }
  int res = sz[1];
  for (int i = 1; i <= nc; i++)
    if (sz[i] > res) res = sz[i];
  printf("%d\n", res);
  return 0;
}
