#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
vector<int> P(N), R(N), S(N);
int find(int x) {
  if (x == P[x]) return x;
  return P[x] = find(P[x]);
}
void join(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    if (R[a] > R[b]) {
      P[b] = a;
      S[a] += S[b];
    } else if (R[a] < R[b]) {
      P[a] = b;
      S[b] += S[a];
    } else {
      R[a]++;
      P[b] = a;
      S[a] += S[b];
    }
  }
}
void solve() {
  int n, k, m;
  scanf("%d", &n), scanf("%d", &k);
  for (int i = 1; i <= n; i++) {
    P[i] = i;
    R[i] = 1;
    S[i] = 1;
  }
  for (int i = 0; i < k; i++) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    join(u, v);
  }
  scanf("%d", &m);
  unordered_set<int> bad;
  int mx = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x), scanf("%d", &y);
    x = find(x), y = find(y);
    if (x == y) {
      bad.insert(x);
    }
  }
  for (int i = 1; i <= n; i++) {
    int x = find(i);
    if (bad.count(x)) continue;
    mx = max(mx, S[find(x)]);
  }
  printf("%d\n", mx);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
