https://pintia.cn/problem-sets/994805046380707840/exam/problems/994805070149828608?type=7&page=1
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define oz 998244353
#define N 200010
#define INF 0x3f3f3f3f
typedef long long ll;
const int mod = 1e9 + 7;
void solve() {
int n;
cin >> n;
vector<set<int>> s(n + 1);
for (int i = 1; i <= n; i++) {
set<int> st;
int m;
cin >> m;
while (m --) {
int x;
cin >> x;
st.insert(x);
}
s[i] = st;
}
int m;
cin >> m;
while (m --) {
int l, r;
cin >> l >> r;
int cnt = 0;
for (auto t : s[l]) {
if (s[r].find(t) != s[r].end())cnt ++;
}
double res = cnt * 100.0 / (s[l].size() + s[r].size() - cnt);
cout << fixed << setprecision(2);
cout << res;
cout << "%" << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}