#include <bits/stdc++.h>
using namespace std;
int dsu[2001];
int size[2001];
void assign(int n) {
  for (int i = 0; i <= n; i++) {
    dsu[i] = i;
    size[i] = 1;
  }
}
int find(int i) {
  while (i != dsu[i]) {
    dsu[i] = dsu[dsu[i]];
    i = dsu[i];
  }
  return i;
}
void unionn(int x, int y) {
  int xx = find(x);
  int yy = find(y);
  if (size[xx] <= size[yy]) {
    size[yy] += size[xx];
    dsu[xx] = yy;
  } else {
    size[xx] += size[yy];
    dsu[yy] = xx;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  assign(n);
  int k;
  cin >> k;
  int x, y;
  for (int i = 0; i < int(k); i++) {
    cin >> x >> y;
    unionn(x, y);
  }
  int m;
  cin >> m;
  for (int i = 0; i < int(m); i++) {
    cin >> x >> y;
    if (find(x) == find(y)) {
      unionn(0, x);
    }
  }
  int NOO = find(0);
  map<int, int> count;
  for (int i = 0; i < int(n + 1); i++) {
    if (find(i) != NOO) {
      count[find(i)]++;
    }
  }
  int MAX = 0;
  for (auto it : count) {
    if (it.second > MAX) MAX = it.second;
  }
  cout << MAX << "\n";
  return 0;
}
