#include <bits/stdc++.h>
using namespace std;
int n, m, s, l, ok[100005], x[100005];
int used[100005];
vector<int> g[100005];
vector<int> gg[100005];
void dfs(int v) {
  used[v] = l;
  ok[l]++;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to]) {
      dfs(to);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (used[i] == 0) {
      l++;
      dfs(i);
    }
  }
  cin >> s;
  for (int i = 1; i <= s; i++) {
    int k, q;
    cin >> k >> q;
    if (used[k] == used[q]) {
      x[used[q]] = 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= l; i++) {
    if (x[i] == 0) {
      ans = max(ans, ok[i]);
    }
  }
  cout << ans;
  return 0;
}
