#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > graph;
int caninvite[2000];
int visited[2000];
int group[2000];
int qg;
int sz;
bool invalid;
void expand(int v) {
  group[v] = qg;
  visited[v] = true;
  for (int i = 0; i < graph[v].size(); ++i) {
    int nv = graph[v][i].first;
    int r = graph[v][i].second;
    if (r) {
      if (!visited[nv]) expand(nv);
    } else {
      if (group[nv] == qg) {
        invalid = true;
      }
    }
  }
  ++sz;
}
int main() {
  memset(visited, 0, sizeof caninvite);
  memset(group, -1, sizeof group);
  int n;
  cin >> n;
  graph.assign(n, vector<pair<int, int> >());
  int k;
  cin >> k;
  int a, b;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    --a;
    --b;
    graph[a].push_back(make_pair(b, 1));
    graph[b].push_back(make_pair(a, 1));
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    --a;
    --b;
    graph[a].push_back(make_pair(b, 0));
    graph[b].push_back(make_pair(a, 0));
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) {
      sz = 0;
      qg = i;
      invalid = false;
      expand(i);
      if (!invalid) ans = max(ans, sz);
    }
  }
  cout << ans << endl;
  return 0;
}
