#include <bits/stdc++.h>
using namespace std;
int n;
int f[2002], num[2002];
void init() {
  for (int i = 1; i <= n; ++i) {
    f[i] = i;
    num[i] = 1;
  }
}
int getroot(int x) { return x == f[x] ? x : f[x] = getroot(f[x]); }
void unions(int x, int y) {
  x = getroot(x);
  y = getroot(y);
  if (x == y) return;
  if (num[x] > num[y]) {
    num[f[y] = x] += num[y];
    num[y] = 0;
  } else {
    num[f[x] = y] += num[x];
    num[x] = 0;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int mmin = 0, x, y, m;
  cin >> n >> m;
  init();
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    unions(x, y);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    if (getroot(x) == getroot(y)) num[getroot(x)] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    mmin = max(mmin, num[i]);
  }
  cout << mmin << endl;
  return 0;
}
