#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> graph(2002);
bool visit[2002];
unordered_set<long long> us;
void dfs(long long n) {
  if (visit[n] == true) return;
  us.insert(n);
  visit[n] = true;
  for (auto u : graph[n]) dfs(u);
}
int main() {
  memset(visit, sizeof(visit), false);
  long long n, m;
  cin >> n;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  long long k;
  cin >> k;
  vector<pair<long long, long long>> vct(k);
  for (long long i = 0; i < k; i++) cin >> vct[i].first >> vct[i].second;
  if (n == 0) {
    cout << "0" << endl;
    exit(0);
  }
  long long max = 0;
  for (long long i = 1; i <= m; i++) {
    us.clear();
    bool condition = true;
    if (visit[i] == false) dfs(i);
    for (long long i = 0; i < k; i++) {
      if (us.find(vct[i].first) != us.end() &&
          us.find(vct[i].second) != us.end()) {
        condition = false;
        break;
      } else
        condition == true;
    }
    if (condition == true) {
      if (us.size() > max) max = us.size();
    }
  }
  bool cond = true;
  for (long long i = 1; i <= n; i++) {
    if (visit[i] == false) cond = false;
  }
  if (cond == false && max == 0)
    cout << 1 << endl;
  else
    cout << max << endl;
}
