#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, set<long long> > friends, hate;
vector<bool> visited;
long long n, m;
set<long long> addedInThisSet;
bool possible;
long long length;
void dfs(int i) {
  if (visited[i]) return;
  visited[i] = true;
  length++;
  for (auto j : addedInThisSet) {
    if (hate[i].count(j)) possible = false;
  }
  addedInThisSet.insert(i);
  for (auto j : friends[i]) {
    dfs(j);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    friends[a].insert(b);
    friends[b].insert(a);
  }
  long long k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    hate[a].insert(b);
    hate[b].insert(a);
  }
  visited.resize(n + 1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (visited[i]) continue;
    possible = true;
    length = 0;
    dfs(i);
    if (possible) {
      ans = max(ans, length);
    }
    addedInThisSet.clear();
  }
  cout << ans;
  return 0;
}
