local ior = io.input() local dic = {} local score = {} local cnt = {} local len = {} local str = "" for i = 1, 3 do cnt[i] = {} end for i = 1, 5 do str = ior:read() local name = str:match("%w+") local num = tonumber(str:match("%d+")) dic[name] = i score[i] = num for j = 1, 3 do cnt[j][i] = 0 end end for i = 1, 3 do len[i] = ior:read("*n", "*l") for j = 1, len[i] do str = ior:read() cnt[i][dic[str]] = cnt[i][dic[str]] + 1 end end local c = {} local e = 0 for i = 1, 5 do c[i] = 5 * cnt[1][i] * cnt[2][i] * cnt[3][i] e = e + c[i] * score[i] / len[1] / len[2] / len[3] end print(string.format("%.8f", e)) for i = 1, 5 do print(c[i]) end