#include <bits/stdc++.h>
using namespace std;
int rela[2000][2000];
int par[2000];
bool dislike[2000][2000];
void init_par(int n) {
  for (int i = 0; i < (n); i++) par[i] = i;
}
int root(int x) { return (par[x] == x ? x : par[x] = root(par[x])); }
void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x != y) {
    (y < x ? par[x] = y : par[y] = x);
  }
}
bool same(int x, int y) { return (root(x) == root(y)); }
int main() {
  memset(rela, 0, sizeof(rela));
  memset(dislike, false, sizeof(dislike));
  int n;
  scanf("%d", &n);
  init_par(n);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < (k); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    unite(a, b);
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < (m); i++) {
    int c, d;
    scanf("%d %d", &c, &d);
    c--;
    d--;
    dislike[c][d] = true;
    dislike[d][c] = true;
  }
  map<int, int> group;
  vector<int> acqu(n);
  for (int i = 0; i < (n); i++) {
    group[root(i)]++;
    acqu[i] = root(i);
  }
  int res = 0;
  map<int, int>::iterator it = group.begin();
  for (; it != group.end(); it++) {
    int g = (*it).first;
    bool found = false;
    if ((*it).second > res) {
      for (int i = 0; i < (n); i++)
        for (int j = 0; j < (n); j++)
          if (i != j && g == acqu[i] && g == acqu[j]) {
            if (dislike[i][j]) {
              found = true;
              break;
            }
          }
      if (!found) {
        res = (*it).second;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
