#include <bits/stdc++.h>
using namespace std;
void bfs(vector<vector<int> >& G, vector<int>& components, vector<int>& sizes,
         int vertex_s, int number_of_component) {
  queue<int> Queue;
  Queue.push(vertex_s);
  components[vertex_s] = number_of_component;
  int current_vertex;
  int cur_size = 1;
  while (!Queue.empty()) {
    current_vertex = Queue.front();
    Queue.pop();
    for (int i = 0; i < G.size(); i++) {
      if ((G[current_vertex][i] == 1) && (components[i] == -1)) {
        components[i] = number_of_component;
        cur_size++;
        Queue.push(i);
      };
    };
  };
  sizes.push_back(cur_size);
}
int main() {
  int N, K, M;
  cin >> N >> K;
  vector<vector<int> > love(N, vector<int>(N, 0));
  vector<vector<int> > hate(N, vector<int>(N, 0));
  for (int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    love[a - 1][b - 1] = love[b - 1][a - 1] = 1;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    hate[a - 1][b - 1] = hate[b - 1][a - 1] = 1;
  }
  vector<int> components(N, -1);
  vector<int> sizes;
  int cur_ver = 0;
  int i = -1;
  while (cur_ver < N) {
    i++;
    bfs(love, components, sizes, cur_ver, i);
    while ((cur_ver < N) && (components[cur_ver] != -1)) {
      cur_ver++;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if ((components[i] == components[j]) && (hate[i][j] == 1))
        sizes[components[i]] = 0;
    }
  }
  int max = 0;
  for (int i = 0; i < sizes.size(); i++) {
    if (max < sizes[i]) max = sizes[i];
  }
  cout << max << endl;
  return 0;
}
