#include #include #include "twix.h" int main() { int M; std::cin >> M; std::vector type, value, root; std::vector> children; for (int i = 0; i < M; ++i) { int N; std::cin >> N; int first = type.size(); for (int j = 0; j < N; ++j) { int t, v = 0; std::vector args; std::cin >> t; if (t == FLAVOR) { std::cin >> v; } else if (t == BUNDLE || t == CHOICE) { int k; std::cin >> k; args.resize(k); for (int& r : args) std::cin >> r; } else { // REPEAT int r; std::cin >> v >> r; args.push_back(r); } for (int& r : args) r += first; type.push_back(t); value.push_back(v); children.push_back(args); } root.push_back(first + N - 1); } std::cout << count_equivalent(M, type, value, children, root) << "\n"; return 0; }