#include <bits/stdc++.h>
int prime[1000000 + 5], in;
bool isp[1000000 + 5];
using namespace std;
vector<int> ar[2005], v1, v2;
int vis[6000000];
int flag[2005][2005];
void dfs(int n) {
  v1.push_back(n);
  vis[n] = 1;
  for (int i = 0; i < ar[n].size(); i++) {
    if (!vis[ar[n][i]]) {
      dfs(ar[n][i]);
    }
  }
}
int main() {
  int n;
  while (cin >> n) {
    v1.clear();
    v2.clear();
    int k;
    cin >> k;
    int a, b;
    for (int i = 0; i < k; i++) {
      cin >> a >> b;
      --a;
      --b;
      ar[a].push_back(b);
      ar[b].push_back(a);
    }
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> a >> b;
      --a;
      --b;
      flag[a][b] = 1;
      flag[b][a] = 1;
    }
    int flu = 0, mx = 0;
    for (int i = 0; i < n; i++) {
      if (!vis[i]) {
        v1.clear();
        dfs(i);
        flu = 1;
        for (int j = 0; j < v1.size() && flu; j++) {
          for (int l = j + 1; l < v1.size() && flu; l++) {
            if (flag[v1[j]][v1[l]]) flu = 0;
          }
        }
        if (flu) mx = max(mx, (int)v1.size());
      }
    }
    cout << mx << endl;
  }
  return 0;
}
