#include // c #include // io #include #include #include #include // container #include #include #include #include #include #include // other #include #include #include #include #include using namespace std; typedef long long ll;typedef unsigned long long ull;typedef long double ld; #define ALL(c) c.begin(),c.end() #define IN(l,v,r) (l<=v && v < r) template void UNIQUE(T& v){v.erase(unique(ALL(v)),v.end());} //debug #define DUMP(x) cerr << #x <<" = " << (x) #define LINE() cerr<< " (L" << __LINE__ << ")" struct range{ struct Iter{ int v,step; Iter& operator++(){v+=step;return *this;} bool operator!=(Iter& itr){return vitr.v;} int& operator*(){return v;} }; Iter i, n; rrange(int i, int n,int step):i({i-1,step}), n({n-1,step}){} rrange(int i, int n):rrange(i,n,1){} rrange(int n) :rrange(0,n){} Iter& begin(){return n;} Iter& end(){return i;} }; //input template istream& operator >> (istream& is,pair& p){return is>>p.first>>p.second;} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t);} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t) >> get<1>(t);} template istream& operator >> (istream& is,tuple& t){return is >>get<0>(t)>>get<1>(t)>>get<2>(t);} template istream& operator >> (istream& is,tuple& t){return is >> get<0>(t)>>get<1>(t)>>get<2>(t)>>get<3>(t);} template istream& operator >> (istream& is,vector& as){for(int i:range(as.size()))is >>as[i];return is;} //output template ostream& operator << (ostream& os, const set& ss){for(auto a:ss){if(a!=ss.begin())os<<" "; os< ostream& operator << (ostream& os, const pair& p){return os< ostream& operator << (ostream& os, const map& m){bool isF=true;for(auto& p:m){if(!isF)os< ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const tuple& t){return os << get<0>(t)<<" "<(t)<<" "<(t)<<" "<(t);} template ostream& operator << (ostream& os, const vector& as){for(int i:range(as.size())){if(i!=0)os<<" "; os< ostream& operator << (ostream& os, const vector>& as){for(int i:range(as.size())){if(i!=0)os< inline T INF(){assert(false);}; template<> inline int INF(){return 1<<28;}; template<> inline ll INF(){return 1LL<<60;}; template<> inline double INF(){return 1e16;}; template<> inline long double INF(){return 1e16;}; template inline T EPS(){assert(false);}; template<> inline int EPS(){return 1;}; template<> inline ll EPS(){return 1LL;}; template<> inline double EPS(){return 1e-8;}; template<> inline long double EPS(){return 1e-8;}; // min{2^r | n < 2^r} template inline T upper_pow2(T n){ T res=1;while(res inline T msb(T n){ int d=62;while((1LL<n)d--;return d;} template T pmod(T v,U M){return (v%M+M)%M;} ll gcd_positive(ll a,ll b) { return b == 0 ? a : gcd_positive(b,a%b); } ll gcd(ll a,ll b) { return gcd_positive(abs(a), abs(b)); } struct Ratio{ ll a,b;// a/b Ratio(){} Ratio(ll a,ll b):a(a),b(b){ll gd =gcd(a,b);this->a/=gd,this->b/=gd;} bool operator < (const Ratio& r) const{ if((b>=0) == (r.b>=0)) return a*r.b < r.a*b; return a*r.b > r.a*b; } bool operator <= (const Ratio& r) const{ if((b>=0) == (r.b>=0)) return a*r.b <= r.a*b; return a*r.b >= r.a*b; } }; ostream& operator << (ostream& os,const Ratio& r){os << r.a<<'/'< T satisfy_mini(Func P,T l ,T r){//(l |sep| r) l -= EPS(); while(r-l>EPS()){ T m=(l+r)/2; (P(m)?r:l)=m; } return r; } class Main{ public: void run(){ // 3辺とって 一点で交わってない iff 正三角形 int N;cin >> N; vector>> es(3); for(int p:range(3))es[p].push_back({1,1}); for(int i:range(N)){ int p; ll a,b;cin >> p >> a >> b; es[p].push_back({a/gcd(a,a+b),(a+b)/gcd(a,a+b)}); } set pset; vector ps; for(int i2:range(es[2].size())){ ps.push_back(Ratio(es[2][i2].first,es[2][i2].second)); pset.insert(Ratio(es[2][i2].first,es[2][i2].second)); } sort(ALL(ps)); ll res = 0; for(int i0:range(es[0].size()))for(int i1:range(es[1].size())){ ll u = ((es[0][i0].second - es[0][i0].first)*es[1][i1].second+(es[1][i1].second - es[1][i1].first)*es[0][i0].second); ll d = es[0][i0].second*es[1][i1].second; if(u > d) continue;// 交点が外 Ratio lv = max( Ratio(es[0][i0].second - es[0][i0].first,es[0][i0].second), Ratio(es[1][i1].second - es[1][i1].first,es[1][i1].second)); int mi = satisfy_mini([&](int i){ return lv <= ps[i]; },0,(int)ps.size()); // cerr << lv <<" " << ps[0] << endl; // cerr << es[2].size() << " " <