#include #include int main() { int n; std::cin >> n; std::set> birds; for (int i = 0; i < n; ++i) { int b; std::cin >> b; for (int j = 0; j < b; ++j) { int en; std::cin >> en; birds.insert({i, en}); } } int res = 0; for (auto aIt = birds.begin(); aIt != birds.end(); ++aIt) { for (auto bIt = aIt; bIt != birds.end(); ++bIt) { if (aIt->first == bIt->first) continue; if (aIt->second > bIt->second) ++res; } } std::cout << res << std::endl; return 0; }