#include <bits/stdc++.h>
using namespace std;
vector<int> V[3000];
int vis[3000];
int k = 1;
int siz[3000];
void dfs(int x) {
  for (int i = 0; i < V[x].size(); i++) {
    if (vis[V[x][i]] == 0) {
      vis[V[x][i]] = k;
      siz[k]++;
      dfs(V[x][i]);
    }
  }
}
int main() {
  int n, kk, m;
  int x, y;
  cin >> n;
  cin >> kk;
  for (int i = 0; i < kk; i++) {
    cin >> x >> y;
    V[x].push_back(y);
    V[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) {
      siz[k]++;
      vis[i] = k;
      dfs(i);
      k++;
    }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (vis[x] == vis[y]) siz[vis[x]] = 0;
  }
  sort(siz, siz + n);
  reverse(siz, siz + n);
  int ans = 0;
  for (int i = 0; siz[i] != 0; i++) ans = max(ans, siz[i]);
  cout << ans << endl;
}
