#include <bits/stdc++.h>
using namespace std;
const int mxN = 2005;
vector<int> adj[mxN];
bool visited[mxN];
int n;
vector<int> comp;
void pre() {}
void dfs(int v) {
  visited[v] = true;
  comp.push_back(v);
  for (auto x : adj[v]) {
    if (!visited[x]) {
      dfs(x);
    }
  }
}
void solve() {
  cin >> n;
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  map<pair<int, int>, int> m1;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    m1[{x, y}] = 1;
    m1[{y, x}] = 1;
  }
  int ans = 0;
  memset(visited, false, sizeof(visited));
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      comp.clear();
      dfs(i);
      int flag = 0;
      for (int j = 0; j < comp.size(); j++) {
        for (int k = j + 1; k < comp.size(); k++) {
          if (m1[{comp[j], comp[k]}] == 1 || m1[{comp[k], comp[j]}] == 1) {
            flag = 1;
            break;
          }
        }
        if (flag) break;
      }
      if (flag == 0) {
        int temp = comp.size();
        ans = max(ans, temp);
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pre();
  int t;
  t = 1;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
