#include <bits/stdc++.h>
using namespace std;
vector<int> friends[2010];
vector<int> enemies[2010];
bool visited[2010];
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    enemies[a].push_back(b);
    enemies[b].push_back(a);
  }
  int best = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      set<int> good;
      set<int> bad;
      stack<int> next;
      next.push(i);
      while (!next.empty()) {
        int v = next.top();
        good.insert(v);
        next.pop();
        if (visited[v]) continue;
        visited[v] = true;
        for (int j = 0; j < friends[v].size(); j++) {
          if (!visited[friends[v][j]]) {
            next.push(friends[v][j]);
          }
        }
        for (int j = 0; j < enemies[v].size(); j++) {
          bad.insert(enemies[v][j]);
        }
      }
      bool found = true;
      for (set<int>::iterator it = good.begin(); it != good.end(); ++it) {
        if (bad.find(*it) != bad.end()) {
          found = false;
          break;
        }
      }
      if (found) {
        if (good.size() > best) best = good.size();
      }
    }
  }
  cout << best << endl;
  return 0;
}
