#include <bits/stdc++.h>
using namespace std;
int l[2010][2010], d[2010][2010];
int computed[2010];
int group[2010];
int n;
int conflict(int s) {
  int size = d[s][0];
  int sizeG = group[0];
  for (int j = 1; j <= sizeG; j++)
    for (int i = 1; i <= size; i++)
      if (d[s][i] == group[j]) {
        return 1;
      }
  return 0;
}
int foo(int s) {
  int size = l[s][0];
  if (conflict(s)) return -1;
  computed[s] = 1;
  group[0]++;
  group[group[0]] = s;
  int sum = 1;
  for (int i = 1; i <= size; i++)
    if (!(computed[l[s][i]] == 1)) {
      int ret = foo(l[s][i]);
      if (ret == -1)
        return -1;
      else
        sum += ret;
    }
  return sum;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) l[i][j] = d[i][j] = computed[i] = 0;
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    int size = l[a][0];
    l[a][size + 1] = b;
    l[a][0]++;
    int sizeB = l[b][0];
    l[b][sizeB + 1] = a;
    l[b][0]++;
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    int size = d[a][0];
    d[a][size + 1] = b;
    d[a][0]++;
    int sizeB = d[b][0];
    d[b][sizeB + 1] = a;
    d[b][0]++;
  }
  int out = 0;
  for (int i = 1; i <= n; i++) {
    group[0] = 0;
    if (!computed[i]) {
      int res = foo(i);
      out = max(out, res);
    }
    int sizeG = group[0];
    for (int j = 1; j <= sizeG; j++) computed[group[j]] = 2;
  }
  printf("%d\n", out);
  return 0;
}
