#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include using namespace std; bool ok0[4003][4003]; bool ok1[4003][4003]; bool ok2[4003][4003]; int main() { int n; cin >> n; vector> a(3), b(3); for (int i = 0; i < 3; i++) { a[i].push_back(1); b[i].push_back(1); } for (int i = 0; i < n; i++) { int p, ta, tb; cin >> p >> ta >> tb; a[p].push_back(ta); b[p].push_back(ta + tb); } int ans = 0; for (int i = 0; i < a[0].size(); i++) { for (int j = 0; j < a[1].size(); j++) { if (a[0][i] * b[1][j] + a[1][j] * b[0][i] >= b[0][i] * b[1][j]) { ok0[i][j] = true; } } } for (int i = 0; i < a[0].size(); i++) { for (int k = 0; k < a[2].size(); k++) { if (a[0][i] * b[2][k] + a[2][k] * b[0][i] >= b[0][i] * b[2][k]) { ok1[i][k] = true; } } } for (int j = 0; j < a[1].size(); j++) { for (int k = 0; k < a[2].size(); k++) { if (a[1][j] * b[2][k] + a[2][k] * b[1][j] >= b[1][j] * b[2][k]) { ok2[j][k] = true; } } } for (int i = 0; i < a[0].size(); i++) { for (int j = 0; j < a[1].size(); j++) { for (int k = 0; k < a[2].size(); k++) { if (ok0[i][j] && ok1[i][k] && ok2[j][k] && a[0][i] * b[1][j] * b[2][k] + a[1][j] * b[0][i] * b[2][k] + a[2][k] * b[0][i] * b[1][j] != 2 * b[0][i] * b[1][j] * b[2][k]) { ans++; } } } } cout << ans << endl; }