#include <bits/stdc++.h>
using namespace std;
vector<int> grav[2050];
int n;
int m, k;
int mark[2050];
bool bad[2050];
int sz[2050];
void dfs(int v, int color) {
  mark[v] = color;
  for (int i = 0; i < (int)grav[v].size(); i++) {
    int u = grav[v][i];
    if (mark[u] == 0) dfs(u, color);
  }
}
int main() {
  int u, v;
  cin >> n;
  cin >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> u >> v;
    --u;
    --v;
    grav[u].push_back(v);
    grav[v].push_back(u);
  }
  int color = 1;
  for (int i = 0; i < (int)(n); i++) {
    if (mark[i] == 0) dfs(i, color++);
    sz[mark[i]]++;
  }
  cin >> k;
  for (int i = 0; i < (int)(k); i++) {
    cin >> u >> v;
    --u;
    --v;
    if (mark[u] == mark[v]) bad[mark[u]] = true;
  }
  int mx = 0;
  for (int c = 1; c < color; ++c) {
    if (!bad[c] && (mx == 0 || sz[c] > sz[mx])) mx = c;
  }
  cout << sz[mx] << endl;
  return 0;
}
