#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 256;
const int N = 1256;
const int INF = int(1e9);
int n, k, m;
vector<int> v[MAXN], g[MAXN];
map<pair<int, int>, bool> M;
int u[MAXN], clr = 1;
void dfs(int x, bool &T, int &comp) {
  u[x] = clr;
  comp++;
  for (int i = 0; i < v[x].size(); ++i) {
    int to = v[x][i];
    if (!u[to]) {
      for (int j = 0; j < g[to].size(); ++j) {
        if (u[g[to][j]] == clr) {
          T = 1;
          break;
        }
      }
      dfs(to, T, comp);
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (!u[i]) {
      bool U = 0;
      int com = 0;
      dfs(i, U, com);
      if (!U) {
        ans = max(ans, com);
      }
      clr++;
    }
  }
  cout << ans;
  return 0;
}
