#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 10, big = 1e18, mod = 1e9 + 7;
vector<long long> a[N], now, ans;
long long n, x, y, m, maxi;
bool vis[N], mp[N][N];
void dfs(long long i) {
  vis[i] = 1, now.push_back(i);
  for (int j = 0; j < a[i].size(); j++)
    if (!vis[a[i][j]]) dfs(a[i][j]);
}
int main() {
  cin >> n;
  cin >> m;
  while (m--) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  cin >> m;
  while (m--) {
    cin >> x >> y;
    mp[x][y] = mp[y][x] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      now.clear();
      dfs(i);
      bool check = 1;
      if (now.size() == 1)
        maxi = max(1LL, maxi);
      else {
        for (int j = 0; j < now.size() - 1; j++)
          for (int k = j + 1; k < now.size(); k++)
            if (mp[now[j]][now[k]]) check = 0;
        if (check) maxi = max((long long)now.size(), maxi);
      }
    }
  cout << maxi;
}
