#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
unordered_map<long long int, set<long long int>> m;
unordered_map<long long int, set<long long int>> ad;
long long int ver = 0;
int dfs(long long int a, long long int visited[], long long int k) {
  visited[a] = k;
  ver++;
  for (auto j : m[a]) {
    if (!visited[j]) {
      dfs(j, visited, k);
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, e, a, b, d;
  cin >> n;
  cin >> e;
  for (long long int i = 0; i < e; i++) {
    cin >> a >> b;
    m[a].insert(b);
    m[b].insert(a);
  }
  cin >> d;
  vector<pair<long long int, long long int>> hate;
  for (long long int i = 0; i < d; i = i + 1) {
    cin >> a >> b;
    hate.push_back({a, b});
  }
  long long int k = 1;
  long long int ans[n + 1];
  long long int visited[n + 1];
  memset(ans, 0, sizeof(ans));
  memset(visited, 0, sizeof(visited));
  for (long long int i = 1; i < n + 1; i = i + 1) {
    if (visited[i] == 0) {
      ver = 0;
      dfs(i, visited, k);
      ans[k] = ver;
      k++;
    }
  }
  for (long long int i = 0; i < hate.size(); i = i + 1) {
    if (visited[hate[i].first] == visited[hate[i].second]) {
      ans[visited[hate[i].first]] = 0;
    }
  }
  long long int ans1 = 0;
  for (long long int i = 0; i <= n; i++) {
    ans1 = max(ans[i], ans1);
  }
  cout << ans1;
  return 0;
}
