#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int exp(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
using namespace std;
vector<vector<long long int>> v(2001);
vector<long long int> parent(2001);
vector<long long int> size(2001, 1);
long long int find_set(long long int x) {
  return parent[x] == x ? x : x = find_set(parent[x]);
}
long long int union_sets(long long int x, long long int y) {
  x = find_set(x);
  y = find_set(y);
  if (x != y) {
    if (size[x] < size[y]) swap(x, y);
    parent[y] = x;
    size[x] = size[x] + size[y];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, x, y, k1, k2, ans = 0;
  cin >> n;
  cin >> k1;
  for (long long int i = 0; i < k1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (long long int i = 1; i < n + 1; i++) parent[i] = i;
  for (long long int i = 1; i < n + 1; i++) {
    for (long long int j = 0; j < v[i].size(); j++) union_sets(i, v[i][j]);
    for (long long int j = 1; j < n + 1; j++) parent[j] = find_set(j);
  }
  cin >> k2;
  for (long long int i = 0; i < k2; i++) {
    cin >> x >> y;
    if (find_set(x) == find_set(y)) size[find_set(x)] = 0;
  }
  for (long long int i = 1; i < n + 1; i++) {
    if (size[i] > ans && parent[i] == i) ans = size[i];
  }
  cout << ans;
  return 0;
}
