You have \(N\) numbers, \(X_{1}, X_{2}, X_{3}, ... , X_{N}\). How many ways you can choose 4 numbers such that their product is a perfect cube. Formally, how many ways you can choose 4 integeres \(a, b, c, d\) and \(1 <= a < b < c < d <= N\) such that product of \(X_{a} , X_{b}, X_{c}, X_{d}\) is a perfect cube.
A number \(Z\) is said to be a perfect cube if there exists an integer \(Y \) such that \(Z = Y^3\).
Since the numbers can be quite large, so instead of giving a number directly, you will be given \(K_{i}\) integers, \(P_{1}, P_{2}, P_{3}, ... , P_{K}\). Formally, each number \(X_{i}\) is a product of \(P_{1}, P_{2}, P_{3}, ... , P_{K}\).
Input Format
First line will contain \(N\).
Each of next \(N\) lines will start with \(K_{i}\). Next \(K_{i}\) integers \(P_{1}, P_{2}, P_{3}, ... , P_{K}\) will be sperated by a space.
\(4 <= N <= 1000\)
\(1 <= K_{i} <= 100\)
\(1 <= P_{j} <= 500\)
Ouput Format
Print only one integer, which is many ways you can choose 4 numbers such that their product is a perfect cube.
Addition Information
For 20 points: \(4 <= N <= 50\), \(1 <= K_{i} <= 25\), \(1 <= P_{j} <= 20\)
For 100 Points: Original constraints.