#include <bits/stdc++.h>
using namespace std;
int parent[2000];
int Find(int x) {
  if (parent[x] != x) parent[x] = Find(parent[x]);
  return parent[x];
}
void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  parent[x] = y;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) parent[i] = i;
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d %d", &u, &v);
    Union(u - 1, v - 1);
  }
  int sz[n];
  memset(sz, 0, sizeof sz);
  for (int i = 0; i < n; ++i) ++sz[Find(i)];
  scanf("%d", &m);
  bool valid[n];
  memset(valid, true, sizeof valid);
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d %d", &u, &v);
    --u;
    --v;
    u = Find(u);
    v = Find(v);
    if (u == v) valid[u] = false;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (valid[i]) ans = max(ans, sz[i]);
  printf("%d\n", ans);
  return 0;
}
