#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<pair<int, int> > v[2001];
int vis[2001];
int ans = 1;
int cn = 0;
int dfs(int x) {
  if (vis[x]) return 0;
  cn++;
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i].second == 0) {
      dfs(v[x][i].first);
    } else {
      if (vis[v[x][i].first]) {
        ans = 0;
        return 0;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back({y, 0});
    v[y].push_back({x, 0});
  }
  int m;
  cin >> m;
  for (int i = 0; i < (m); ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back({y, 1});
    v[y].push_back({x, 1});
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      memset(vis, 0, sizeof(vis));
      cn = 0;
      ans = 1;
      dfs(i);
      if (ans == 1) {
        mx = max(cn, mx);
      }
    }
  }
  cout << mx;
  return 0;
}
