int n, m, b; std::cin >> n >> m >> b; std::vector<int> x(n), k(n), mask(n); for (int i = 0; i < n; i += 1) { int cnt; std::cin >> x[i] >> k[i] >> cnt; for (int j = 0; j < cnt; j += 1) { int id; std::cin >> id; mask[i] = 1 << (id - 1); } }
std::vector<int> order(n); std::iota(order.begin(), order.end(), 0); std::sort(order.begin(), order.end(), [&](int i, int j) { return k[i] < k[j]; });
constexprstaticint64_t inf = std::numeric_limits<int64_t>::max() / 2; int64_t ans = inf; std::vector<int64_t> dp(1 << m, inf); dp[0] = 0;
for (int i = 0; i < n; i += 1) { for (int j = 0; j < 1 << m; j += 1) { dp[j | mask[order[i]]] = std::min(dp[j | mask[order[i]]], dp[j] + x[order[i]]); } ans = std::min(ans, dp[(1 << m) - 1] + int64_t(1) * k[order[i]] * b); }