#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000;
int n, k, m;
vector<int> v[MAXN];
int x, y;
bool u[MAXN][MAXN];
vector<vector<int> > a;
bool vis[MAXN];
int sum;
void dfs(int uu) {
  vis[uu] = true;
  for (int i = 0; i < (int)(v[uu].size()); i++)
    if (!vis[v[uu][i]]) dfs(v[uu][i]);
  a.back().push_back(uu);
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (int)(k); i++) {
    cin >> x >> y;
    x--, y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> m;
  for (int i = 0; i < (int)(m); i++) {
    cin >> x >> y;
    x--, y--;
    u[x][y] = true;
    u[y][x] = true;
  }
  for (int i = 0; i < (int)(n); i++)
    if (!vis[i]) {
      a.push_back(vector<int>());
      dfs(i);
    }
  for (int i = 0; i < (int)(a.size()); i++) {
    bool flag = true;
    for (int j = 0; j < (int)(a[i].size()); j++) {
      for (int l = j + 1; l < a[i].size(); l++) {
        if (u[a[i][j]][a[i][l]]) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    if (flag) sum = max(sum, (int)a[i].size());
  }
  cout << sum << endl;
}
