#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> adj[N], dislikes[N];
int vis[N];
set<int> temp;
int mx = 0;
int vid = 1;
int ans = 0;
void DFS(int u) {
  vis[u] = vid;
  for (int i : adj[u])
    if (!vis[i]) DFS(i), temp.insert(i);
}
int main() {
  int n;
  scanf("%d", &n);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    dislikes[u].push_back(v);
    dislikes[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    if (!vis[i]) {
      temp.insert(i);
      DFS(i);
      cnt = temp.size();
      for (auto it = temp.begin(); it != temp.end(); it++) {
        for (auto it1 = it; it1 != temp.end(); it1++) {
          auto found = find(dislikes[*it].begin(), dislikes[*it].end(), *it1);
          if (found != dislikes[*it].end()) {
            cnt = 0;
            break;
          }
        }
        if (!cnt) break;
      }
    }
    ans = max(ans, cnt);
    temp.clear();
  }
  cout << ans << endl;
  return 0;
}
