#include <bits/stdc++.h>
using namespace std;
int l = 0;
bool yes = true;
set<int> dislike;
void dfs(vector<int> graph[], vector<int> enemy[], bool visited[], bool vi[],
         int node) {
  visited[node] = true;
  vi[node] = true;
  l++;
  for (auto itr : enemy[node]) {
    dislike.insert(itr);
  }
  for (auto itr : graph[node]) {
    if (!visited[itr]) {
      if (find(dislike.begin(), dislike.end(), itr) != dislike.end()) {
        l = 0;
        yes = false;
        return;
      }
      dfs(graph, enemy, visited, vi, itr);
    }
  }
}
int main() {
  int n, k, m;
  cin >> n >> k;
  vector<int> graph[n + 1];
  int u, v;
  for (int i = 1; i <= k; i++) {
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  cin >> m;
  vector<int> enemy[n + 1];
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    enemy[u].push_back(v);
    enemy[v].push_back(u);
  }
  int answer = 0;
  bool visited[n + 1], vi[n + 1];
  memset(vi, false, sizeof(vi));
  for (int i = 1; i <= n; i++) {
    if (!vi[i]) {
      memset(visited, false, sizeof(visited));
      l = 0;
      yes = true;
      dfs(graph, enemy, visited, vi, i);
      if (yes) {
        answer = max(answer, l);
      }
      dislike.clear();
    }
  }
  cout << answer;
  return 0;
}
