#include #include #include int main() { int n; std::cin >> n; std::vector> birds(n); 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[i].push_back(en); } } int res = 0; for (size_t a = 0; a < n; ++a) { for (int birdA : birds[a]) { for (size_t b = a + 1; b < n; ++b) { for (int birdB : birds[b]) { if (birdA > birdB) res++; } } } } std::cout << res << std::endl; return 0; }