#include<bits/stdc++.h> #define ll long long #define INF 1e9 usingnamespace std; int n, k, m, ans; // ans 需初始化为 0 int cnt[2005], fa[2005]; bool vis[2005]; // 标记 intfind_root(int n){ // 查找根 if (fa[n] == n) return n; return fa[n] = find_root(fa[n]); } voidmerge(int x, int y){ // 合并 int sx = find_root(x), sy = find_root(y); if (sx != sy) fa[sx] = sy; } signedmain(){ ios :: sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= n; i++) fa[i] = i; // 预处理 for (int i = 1; i <= k; i++) { int u, v; cin >> u >> v; merge(u, v); } for (int i = 1; i <= n; i++) cnt[find_root(i)]++; // 统计派对人数 cin >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; if (find_root(x) == find_root(y)) vis[find_root(x)] = 1; // 标记关系 } for (int i = 1; i <= n; i++) { if (!vis[find_root(i)]) ans = max(ans, cnt[find_root(i)]); // 如果没有讨厌的人就更新最大值 } cout << ans; return0; }