#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int (i)=0; (i)<(n) ;++(i)) #define REPN(i,a,n) FOR((i),(a),(a)+(n)) #define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i)) #define PB push_back #define MP make_pair #define SE second #define FI first #define DBG(a) cerr<<(a)< PLL; typedef vector VLL; typedef pairPI; typedef vector VI; const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7; PLL add(PLL a, PLL b){ LL g=__gcd(a.SE,b.SE); return MP((a.FI*b.SE+a.SE*b.FI)/g,a.SE*b.SE/g); } bool comp(PLL a, PLL b){ return a.FI*b.SE a, pair b){ return comp(a.FI,b.FI) or (a.FI==b.FI and comp(a.SE,b.SE)); } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector> l(3); vector> sum,mi; REP(i,n){ LL a,b,c; cin >> a >>b >> c; LL g=__gcd(b,c); l[a].emplace_back(b/g,(b+c)/g); } REP(i,3)l[i].emplace_back(1,1); REP(i,l[0].size()){ REP(j,l[1].size()){ PLL t; //cout<