#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, const uint_fast32_t Q, const std::vector& M, const std::vector>& F) noexcept { uint_fast32_t total = 0; for (uint_fast32_t i = 0; i != Q; ++i) { [[assume(std::is_sorted(F.begin(), F.end()))]]; total += check(M[i], X, F[i]); } 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 M(Q); std::vector> F(Q); for (uint_fast32_t i = 0; i != Q; ++i) { std::cin >> M[i]; F[i].resize(M[i]); for (auto& f : F[i]) std::cin >> f; } for (auto& f : F) std::sort(f.begin(), f.end()); std::cout << std::fixed << std::setprecision(10) << solve(N, X, Q, M, std::move(F)) << '\n'; return 0; }