#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, f, m, x, y;
vector<int> v[2100], v2[2100];
int tanda[2100];
bool bole;
void cari(int x) {
  int i;
  if (tanda[x] == 3) bole = 1;
  tanda[x] = 2;
  for (i = 0; i < v2[x].size(); i++)
    if (tanda[v2[x][i]] == 2)
      bole = 1;
    else
      tanda[v2[x][i]] = 3;
  for (i = 0; i < v[x].size(); i++)
    if (tanda[v[x][i]] != 2) cari(v[x][i]);
}
int main() {
  scanf("%d", &a);
  scanf("%d", &b);
  m = 0;
  memset(tanda, 0, sizeof(tanda));
  for (c = 1; c <= b; c++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  scanf("%d", &d);
  for (c = 1; c <= d; c++) {
    scanf("%d %d", &x, &y);
    v2[x].push_back(y);
    v2[y].push_back(x);
  }
  for (c = 1; c <= a; c++) {
    bole = 0;
    if (tanda[c] == 0) cari(c);
    if (bole == 0) {
      f = 0;
      for (e = 1; e <= a; e++)
        if (tanda[e] == 2) {
          f++;
          tanda[e] = 1;
        } else if (tanda[e] == 3)
          tanda[e] = 0;
      m = max(m, f);
    } else {
      for (e = 1; e <= a; e++)
        if (tanda[e] == 2) {
          tanda[e] = 1;
        } else if (tanda[e] == 3)
          tanda[e] = 0;
    }
  }
  printf("%d\n", m);
}
