#include <bits/stdc++.h>
using namespace std;
long long int n, k, m;
map<pair<long long int, long long int>, long long int> mp;
vector<vector<long long int>> v(2005);
vector<long long int> vis;
vector<long long int> s;
void dfs(long long int r) {
  vis[r] = 1;
  s.push_back(r);
  for (auto cc : v[r]) {
    if (vis[cc] == 0) {
      dfs(cc);
    }
  }
}
int32_t main() {
  cin >> n;
  vis.resize(n + 1, 0);
  v.resize(n + 1);
  long long int mx = 0;
  cin >> k;
  for (long long int i = 0; i < k; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    mp[make_pair(x, y)]++;
    mp[make_pair(y, x)]++;
  }
  vector<vector<long long int>> v;
  for (long long int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vector<long long int> t;
      dfs(i);
      v.push_back(s);
      s = t;
    }
  }
  for (long long int i = 0; i < v.size(); i++) {
    long long int in = 0;
    for (long long int j = 0; j < v[i].size() - 1; j++) {
      for (long long int jj = j + 1; jj < v[i].size(); jj++) {
        if (mp[{v[i][j], v[i][jj]}] > 0 || mp[{v[i][jj], v[i][j]}] > 0) in++;
      }
    }
    long long int xx = v[i].size();
    if (in == 0) mx = max(mx, xx);
  }
  cout << mx << endl;
  return 0;
}
