#include <bits/stdc++.h>
using namespace std;
int n, m, c[2001], col, num[2001], t1, t2, t3;
vector<int> adj[2001];
int dfs(int v) {
  c[v] = col;
  int s = 1;
  for (int i = 0; i < adj[v].size(); i++) {
    if (c[adj[v][i]] == 0) {
      s += dfs(adj[v][i]);
    }
  }
  return s;
}
int main() {
  cin >> n;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> t1 >> t2;
    adj[t1].push_back(t2);
    adj[t2].push_back(t1);
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] == 0) {
      col++;
      t3 = dfs(i);
      num[col] = t3;
    }
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> t1 >> t2;
    if (c[t1] == c[t2]) num[c[t1]] = 0;
  }
  int ma = 0;
  for (int i = 1; i <= col; i++) {
    if (ma < num[i]) ma = num[i];
  }
  cout << ma << endl;
  cin.get();
  cin.get();
  return 0;
}
