#include <bits/stdc++.h>
#define MAX 1000001
#define INF 1000000000000000000
#define M 1000000007
#define ll long long
#define zero(x) memset(x,0,sizeof(x))
using namespace std;
map<double,ll> mp;
vector<double> v;
vector<ll> use;
int tot;
ll dp[MAX][4];
int main(){
int n;
cin >> n;
tot = 0;
for (int i=0;i<n;i++){
double waste,num,den;
cin >> num >> den >> waste;
double sl;
if (!den) sl = INF;
else sl = num/den;
if (!mp[sl]){
v.push_back(sl);
tot++;
}
mp[sl]++;
}
for (int i=0;i<tot;i++) use.push_back(mp[v[i]]);
if (tot<3){
cout << 0;
return 0;
}
for(int i=0;i<3;i++) dp[tot][i] = 1;
for(int i=0;i<=tot;i++) dp[i][3] = 1;
for (int i=tot-1;i>=0;i--){
for (int j=2;j>=0;j--){
if (i==(tot-(3-j))) dp[i][j] = use[i]*dp[i+1][j+1];
else dp[i][j] = dp[i+1][j]+dp[i+1][j+1]*use[i];
}
}
cout << dp[0][0];
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgTUFYIDEwMDAwMDEKI2RlZmluZSBJTkYgMTAwMDAwMDAwMDAwMDAwMDAwMAojZGVmaW5lIE0gMTAwMDAwMDAwNwojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHplcm8oeCkgbWVtc2V0KHgsMCxzaXplb2YoeCkpCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgptYXA8ZG91YmxlLGxsPiBtcDsKdmVjdG9yPGRvdWJsZT4gdjsKdmVjdG9yPGxsPiB1c2U7CmludCB0b3Q7CgpsbCBkcFtNQVhdWzRdOwoKaW50IG1haW4oKXsKCWludCBuOwoJY2luID4+IG47Cgl0b3QgPSAwOwoJZm9yIChpbnQgaT0wO2k8bjtpKyspewoJCWRvdWJsZSB3YXN0ZSxudW0sZGVuOwoJCWNpbiA+PiBudW0gPj4gZGVuID4+IHdhc3RlOwoJCWRvdWJsZSBzbDsKCQlpZiAoIWRlbikgc2wgPSBJTkY7Cgk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