#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.141593;
const long long mod = 1000000007;
const long long INF = 1e15;
const long long nax = 1e5 + 5;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
string ds = "RLDU";
long long parent[200001] = {0};
long long size[200001] = {0};
long long vi[200001] = {0};
long long find_set(long long v) {
  if (parent[v] == v) return v;
  find_set(parent[v]);
}
void unite(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    parent[b] = a;
    size[a] += size[b];
  }
}
int32_t main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    parent[i] = i;
    size[i] = 1;
  }
  for (long long i = 0; i < k; i++) {
    long long u, v;
    cin >> u >> v;
    unite(u, v);
  }
  long long m;
  cin >> m;
  map<long long, long long> M;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    long long a = find_set(u);
    long long b = find_set(v);
    if (a == b) M[a] = 1;
  }
  long long mx = 0;
  for (long long i = 1; i <= n; i++) {
    if (M[find_set(i)] == 0) {
      mx = max(mx, size[find_set(i)]);
    }
  }
  cout << mx << "\n";
}
