#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int const maxn = 2e3 + 5;
long long int const inf = 1e18;
long long int add(long long int a, long long int b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long int mul(long long int a, long long int b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long int powm(long long int x, long long int n, long long int M) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
bool prime(long long int x) {
  if (x < 2) return false;
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long int P[maxn];
long long int sz[maxn];
long long int find_set(long long int x) {
  if (x != P[x]) P[x] = find_set(P[x]);
  return P[x];
}
void merge_set(long long int a, long long int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sz[b] >= sz[a]) swap(a, b);
    P[b] = a;
    sz[a] += sz[b];
    sz[b] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i <= 2000; i++) {
    P[i] = i;
    sz[i] = 1;
  }
  long long int n;
  cin >> n;
  long long int k;
  cin >> k;
  while (k--) {
    long long int x, y;
    cin >> x >> y;
    if (find_set(x) != find_set(y)) {
      merge_set(x, y);
    }
  }
  long long int m;
  cin >> m;
  while (m--) {
    long long int x, y;
    cin >> x >> y;
    x = find_set(x);
    y = find_set(y);
    if (x == y) {
      sz[x] = 0;
      sz[y] = 0;
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, sz[P[i]]);
  cout << ans << "\n";
  return 0;
}
