#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > friends(2020, vector<int>());
vector<vector<int> > enemies(2020, vector<int>());
bitset<2020> notgood;
bitset<2020> visited;
bool toremove = false;
void dfs1_launcher(int from, int to) {
  if (notgood.test(from)) return;
  if (from == to) {
    toremove = true;
    visited.set(from);
    return;
  }
  if (visited.test(from)) return;
  visited.set(from);
  for (typeof((friends[from]).begin()) frnd = (friends[from]).begin();
       frnd != (friends[from]).end(); frnd++) {
    dfs1_launcher(*frnd, to);
  }
}
bool dfs2_launcher(int from) {
  if (notgood.test(from)) return false;
  if (visited.test(from)) return true;
  visited.set(from);
  for (typeof((friends[from]).begin()) frnd = (friends[from]).begin();
       frnd != (friends[from]).end(); frnd++) {
    if (!dfs2_launcher(*frnd)) return false;
  }
  return true;
}
void dfs1(int from, int to) {
  dfs1_launcher(from, to);
  if (toremove) {
    notgood |= visited;
  }
  toremove = false;
  visited.reset();
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  int k;
  int m;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    friends[from].push_back(to);
    friends[to].push_back(from);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    enemies[from].push_back(to);
    enemies[to].push_back(from);
    dfs1(from, to);
    dfs1(to, from);
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (dfs2_launcher(i)) {
      mx = max(mx, (int)visited.count());
    }
    visited.reset();
  }
  cout << mx << endl;
  return 0;
}
