#include <bits/stdc++.h>
using namespace std;
int friends[2001][2001];
int enemies[2001][2001];
int vis[2001];
void dfs(int v, vector<int> &gr, int &n) {
  vis[v] = 1;
  gr.push_back(v);
  for (int i = 1; i <= n; i++) {
    if (friends[v][i] && vis[i] == 0) {
      dfs(i, gr, n);
    }
  }
  return;
}
bool noenemy(vector<int> &gr) {
  for (int i = 0; i < gr.size() - 1; i++) {
    for (int j = i + 1; j < gr.size(); j++) {
      if (enemies[gr[i]][gr[j]]) {
        return 0;
      }
    }
  }
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= 2000; i++) {
    for (int j = 0; j <= 2000; j++) {
      friends[i][j] = 0;
      enemies[2001][2001] = 0;
      vis[i] = 0;
    }
  }
  int k;
  cin >> k;
  while (k) {
    int u, v;
    cin >> u >> v;
    friends[u][v] = 1;
    friends[v][u] = 1;
    k--;
  }
  int m;
  cin >> m;
  while (m) {
    int u, v;
    cin >> u >> v;
    enemies[u][v] = 1;
    enemies[v][u] = 1;
    m--;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vector<int> gr;
      dfs(i, gr, n);
      if (noenemy(gr)) {
        ans = max(ans, (int)gr.size());
      }
    }
  }
  cout << ans;
  return 0;
}
