#include <bits/stdc++.h>
using namespace std;
vector<int> grafo[2000];
set<int> nemici[2000];
int rapp[2000];
list<int> liste[2000];
int N, k, m, maxi = 0;
int main(void) {
  cin >> N;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int da, a;
    cin >> da >> a;
    da--;
    a--;
    grafo[da].push_back(a);
    grafo[a].push_back(da);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int da, a;
    cin >> da >> a;
    da--;
    a--;
    nemici[da].insert(a);
    nemici[a].insert(da);
  }
  for (int i = 0; i < N; i++) {
    rapp[i] = i;
    liste[i].push_back(i);
  }
  for (int i = 0; i < N; i++)
    for (int k = 0; k < grafo[i].size(); k++) {
      int a = grafo[i][k];
      if (rapp[i] != rapp[a]) {
        int rpicc, rgrand;
        if (liste[rapp[i]].size() <= liste[rapp[a]].size()) {
          rpicc = rapp[i];
          rgrand = rapp[a];
        } else {
          rpicc = rapp[a];
          rgrand = rapp[i];
        }
        for (list<int>::iterator it = liste[rpicc].begin();
             it != liste[rpicc].end(); it++)
          rapp[*it] = rgrand;
        liste[rgrand].merge(liste[rpicc]);
      }
    }
  for (int i = 0; i < N; i++) {
    if (liste[i].size() > maxi) {
      for (list<int>::iterator it = liste[i].begin(); it != liste[i].end();
           it++)
        for (list<int>::iterator sec = it; sec != liste[i].end(); sec++)
          if (*it != *sec && nemici[*it].find(*sec) != nemici[*it].end())
            goto next;
      maxi = max(maxi, (int)liste[i].size());
    }
  next:;
  }
  cout << maxi;
  return 0;
}
