#include <bits/stdc++.h>
using namespace std;
long long ran[200009];
long long parent[200009];
long long find(long long i) {
  if (parent[i] == i) {
    return i;
  }
  return parent[i] = find(parent[i]);
}
void merge(long long i, long long j) {
  long long pi = find(i);
  long long pj = find(j);
  long long r1 = ran[pi];
  long long r2 = ran[pj];
  if (pi == pj) return;
  if (r1 < r2) {
    parent[pi] = pj;
  } else if (r1 == r2) {
    parent[pj] = pi;
    ran[pi]++;
  } else {
    parent[pj] = pi;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long z[n + 1];
  for (long long i = 0; i < n + 1; i++) {
    ran[i] = 0;
    z[i] = 0;
    parent[i] = i;
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    merge(x, y);
  }
  long long p;
  cin >> p;
  for (long long i = 0; i < p; i++) {
    long long x, y;
    cin >> x >> y;
    x = find(x);
    y = find(y);
    if (x == y) {
      z[x] = -1;
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    long long x = find(i);
    if (z[x] != -1) z[x]++;
  }
  long long c = 0;
  for (long long i = 1; i < n + 1; i++) c = max(c, z[i]);
  cout << c << endl;
  return 0;
}
