#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> used;
vector<int> res;
void dfs(int v) {
  used[v] = 1;
  res.push_back(v);
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (!used[to]) dfs(to);
  }
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  used.resize(n);
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int q, p;
    cin >> q >> p;
    g[q - 1].push_back(p - 1);
    g[p - 1].push_back(q - 1);
  }
  int k;
  cin >> k;
  vector<vector<bool> > hate(n, vector<bool>(n));
  int max = 0;
  for (int i = 0; i < k; ++i) {
    int q, p;
    cin >> q >> p;
    hate[q - 1][p - 1] = 1;
    hate[p - 1][q - 1] = 1;
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      res.clear();
      dfs(i);
      bool noh = 1;
      for (int si = 0; si < res.size(); ++si)
        for (int sj = 0; sj < res.size(); ++sj)
          if (hate[res[si]][res[sj]] == 1) noh = 0;
      if (noh) max = (res.size() > max) ? res.size() : max;
    }
  }
  cout << max;
}
