#include <bits/stdc++.h>
using namespace std;
struct djset {
  int set_size;
  djset *rep;
};
inline djset *create_set(int n) {
  djset *node = (djset *)malloc(sizeof(djset));
  node->set_size = 1;
  node->rep = node;
  return node;
}
djset *find_set(djset *a) {
  if (a->rep != a) {
    a->rep = find_set(a->rep);
  }
  return a->rep;
}
inline void merge_sets(djset *a, djset *b) {
  a = find_set(a);
  b = find_set(b);
  if (a == b) {
    return;
  }
  if (a->set_size > b->set_size) {
    b->rep = a;
    a->set_size += b->set_size;
    b->set_size = 0;
  } else if (a->set_size < b->set_size) {
    a->rep = b;
    b->set_size += a->set_size;
    a->set_size = 0;
  } else {
    b->rep = a;
    a->set_size += b->set_size;
    b->set_size = 0;
  }
}
int main() {
  int n, k, m, a, b;
  int i, j;
  scanf("%d", &n);
  djset **dja = (djset **)malloc((n + 1) * sizeof(djset *));
  for (i = 1; i <= n; i++) {
    dja[i] = create_set(i);
  }
  scanf("%d", &k);
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &a, &b);
    if (find_set(dja[a]) != find_set(dja[b])) {
      merge_sets(dja[a], dja[b]);
    }
  }
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    if (find_set(dja[a]) == find_set(dja[b])) {
      find_set(dja[a])->set_size = 0;
      find_set(dja[b])->set_size = 0;
    }
  }
  int max = 0;
  for (i = 1; i <= n; i++) {
    max = ((max) >= (dja[i]->set_size) ? (max) : (dja[i]->set_size));
  }
  printf("%d\n", max);
  return 0;
}
