#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
const long long INF = 1e15;
const long long MOD = 1000000007;
int n, m, k, t;
int f[N], f1[N], a[N];
vector<int> v[N];
void dfs(int u, int x) {
  f[u] = x;
  t++;
  int l = v[u].size();
  for (int i = 0; i < l; i++)
    if (!f[v[u][i]]) dfs(v[u][i], x);
}
int main() {
  ios::sync_with_stdio(false);
  ifstream inf("input.txt");
  cin >> n;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int h = 0;
  for (int i = 1; i <= n; i++)
    if (!f[i]) {
      t = 0;
      h++;
      dfs(i, h);
      a[h] = t;
    }
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int x, y;
    cin >> x >> y;
    if (f[x] == f[y]) f1[f[x]] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= h; i++)
    if (!f1[i]) ans = max(ans, a[i]);
  cout << ans;
}
