#include <bits/stdc++.h>
using namespace std;
long long int find_parent(long long int parent[], long long int i) {
  while (parent[i] != i) i = parent[i];
  return i;
}
void Union(long long int parent[], long long int i, long long int j) {
  long long int pii = find_parent(parent, i);
  long long int pj = find_parent(parent, j);
  if (pii != pj) parent[pj] = pii, parent[j] = pii;
}
void test_case() {
  long long int n;
  cin >> n;
  long long int m;
  cin >> m;
  long long int parent[n];
  for (long long int i = 0; i < n; i++) parent[i] = i;
  while (m--) {
    long long int x, y;
    cin >> x >> y;
    Union(parent, x - 1, y - 1);
  }
  unordered_map<long long int, long long int> mp;
  for (long long int i = 0; i < n; i++) {
    long long int p = find_parent(parent, i);
    mp[p]++;
  }
  cin >> m;
  while (m--) {
    long long int x, y;
    cin >> x >> y;
    if (find_parent(parent, x - 1) == find_parent(parent, y - 1)) {
      mp[find_parent(parent, x - 1)] = -1;
    }
  }
  long long int max = 0;
  for (auto x : mp)
    if (x.second > max) max = x.second;
  cout << max << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) test_case();
  return 0;
}
