#include<vector>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<map>
using namespace std;
const int N=51;
set<int>st[N];
void compare(int a, int b)
{
int differentnum=st[b].size(), samenum = 0;
for (auto it : st[a])
{
if (st[b].find(it) != st[b].end())
{
samenum++;
}
else
differentnum++;
}
printf("%.1f%%
", samenum * 100.0 / differentnum);
}
int main()
{
int n,m,temp; cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> m;
for (int j = 0; j < m; j++)
{
cin >> temp;
st[i].insert(temp);
}
}
int queryn, a, b;
cin >> queryn;
for (int i = 0; i < queryn; i++)
{
cin >> a >> b;
compare(a, b);
}
}