#include <bits/stdc++.h>
using namespace std;
vector<int> G[2002];
int mat[2002][2002];
vector<int> te;
int vis[2002];
void go(int i) {
  vis[i] = 1;
  te.push_back(i);
  for (int j = 0; j < G[i].size(); j++) {
    int v = G[i][j];
    if (vis[v] == 0) {
      go(v);
    }
  }
}
int main() {
  int n, m, k;
  cin >> n;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    mat[a][b] = 1;
    mat[b][a] = 1;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      te.clear();
      go(i);
      int ok = 1;
      for (int i = 0; i < te.size() && ok; i++) {
        for (int j = i + 1; j < te.size() && ok; j++) {
          if (mat[te[i]][te[j]] == 1) {
            ok = 0;
          }
        }
      }
      if (ok == 1) {
        mx = max(mx, (int)te.size());
      }
    }
  }
  cout << mx << "\n";
  return 0;
}
