#include <bits/stdc++.h>
using namespace std;
vector<int> v[2003];
set<int> s[2003], temp;
int ans[2003];
bool vis[2003];
int cnt = 0;
void dfs(int x) {
  temp.insert(x);
  vis[x] = 1;
  cnt++;
  for (int i = 0; i < v[x].size(); i++) {
    if (!vis[v[x][i]]) dfs(v[x][i]);
  }
}
int main() {
  int bla = 0;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    s[a].insert(b);
    s[b].insert(a);
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == 0) {
      temp.clear();
      cnt = 0;
      dfs(i);
      for (auto nx : temp) {
        for (auto nx1 : s[nx]) {
          if (temp.find(nx1) != temp.end()) {
            cnt = -1;
            break;
          }
        }
        if (cnt == -1) break;
      }
      for (auto nx : temp) {
        ans[nx] = cnt;
      }
      bla = max(bla, cnt);
    }
    if (ans[i] == 0) ans[i] = 1;
    bla = max(bla, ans[i]);
  }
  cout << bla << endl;
}
