#include <bits/stdc++.h>
using namespace std;
int f[2048], z[2048];
int rt(int x) { return (x == f[x] ? x : (f[x] = rt(f[x]))); }
int main(void) {
  int n, m, v = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) f[i] = i, z[i] = 1;
  for (int i = 0, a, b; i < m && cin >> a >> b; ++i) {
    a = rt(a), b = rt(b);
    if (a != b) f[b] = a, z[a] += z[b];
  }
  cin >> m;
  for (int i = 0, a, b; i < m && cin >> a >> b; ++i) {
    a = rt(a), b = rt(b);
    if (a == b) z[a] = 0;
  }
  for (int i = 1; i <= n; ++i)
    if (i == rt(i) && z[i] > v) v = z[i];
  cout << v << endl;
  return 0;
}
