#include using namespace std; #define rep(i,a,b) for(int i=a;i vec[3]; ld EPS = 1e-18; //----------------------------------------------------------------------------------- int count() { int ans = 0; for (ld a : vec[0]) for (ld b : vec[1]) { for (ld c : vec[2]) { ld sum = a + b + c; if (abs(1 - sum) < EPS) continue; ld ab = a + b; ld bc = b + c; ld ac = a + c; if (ab <= 1 && bc <= 1 && ac <= 1) ans++; } } return ans; } //----------------------------------------------------------------------------------- int main() { cin >> N; rep(i, 0, 3) vec[i].push_back(0); rep(i, 0, N) { int P, A, B; scanf("%d%d%d", &P, &A, &B); vec[P].push_back((ld)B / (ld)(A + B)); } cout << count() << endl; }