#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > v(100010);
map<long long, long long> fr;
map<pair<long long, long long>, long long> enemy;
vector<pair<long long, long long> > en;
vector<bool> th(100010), vi(100010);
long long DFS(long long n) {
  stack<long long> s;
  long long ans = 0;
  vector<long long> e;
  vi[n] = true;
  long long fl = 0;
  s.push(n);
  if (fr[n] == 1) e.push_back(n);
  ans++;
  while (s.size() > 0) {
    long long x = s.top();
    s.pop();
    for (long long i = 0; i < v[x].size(); i++) {
      if (vi[v[x][i]] == false) {
        s.push(v[x][i]);
        ans++;
        if (fr[v[x][i]] == 1 && fl == 0) {
          for (long long j = 0; j < e.size(); j++) {
            if (enemy[make_pair(v[x][i], e[j])] == 1) {
              ans = 0;
              fl = 1;
            }
          }
          e.push_back(v[x][i]);
        }
        vi[v[x][i]] = true;
      }
    }
  }
  if (fl == 1) return 0;
  return ans;
}
int main() {
  long long n, m, i, k;
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    en.push_back(make_pair(x, y));
    fr[x] = fr[y] = 1;
    enemy[make_pair(x, y)] = enemy[make_pair(y, x)] = 1;
  }
  long long max = 0;
  for (i = 1; i <= n; i++) {
    if (vi[i] == 0) {
      long long z = DFS(i);
      if (z > max) {
        max = z;
      }
    }
  }
  cout << max;
}
