#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include using namespace std; 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]) { continue; } 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]) { continue; } if (a[0][i] * b[2][k] + a[2][k] * b[0][i] < b[0][i] * b[2][k]) { continue; } if (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; }