#include [[nodiscard]] static inline constexpr uint_fast32_t check(const uint_fast32_t M, const uint_fast32_t X, const std::vector& F) noexcept { [[assume(std::is_sorted(F.begin(), F.end()))]]; if (std::binary_search(F.begin(), F.end(), X)) return 2; for (uint_fast32_t i = 1; i < M; ++i) if (F[i] == F[i - 1]) return 1; return 0; } [[nodiscard]] static inline constexpr double solve([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t X, [[maybe_unused]] const uint_fast32_t Q, const std::vector>>& turns) noexcept { uint_fast32_t total = 0; for (const auto& [M, F] : turns) { [[assume(std::is_sorted(F.begin(), F.end()))]]; total += check(M, X, F); } return total / 2.0; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, X, Q; std::cin >> N >> X >> Q; std::vector>> turns(Q); for (auto& [M, F] : turns) { std::cin >> M; F.resize(M); for (auto& f : F) std::cin >> f; } for (auto& [M, F] : turns) std::sort(F.begin(), F.end()); std::cout << std::fixed << std::setprecision(10) << solve(N, X, Q, turns) << '\n'; return 0; }