#include using namespace std; using ll=long long; using ld= long double; using P=pair; using V=vector; #define rep(i,n) for(ll i=0;i f(nh,V(nw)),f1(nh,V(nw)),f2(nh,V(nw)); while(true){ rep(i,nh-1){ f[i]=f[i+1]; f1[i]=f1[i+1]; f2[i]=f2[i+1]; } rep(j,nw) f[nh-1][j]=f1[nh-1][j]=f2[nh-1][j]=0; int n; cin >> n; if(n==-1) break; rep(i,n){ int h,p,x; cin >> h >> p >> x; x--; f[nh-1][x]=f1[nh-1][x]=h; f2[nh-1][x]=p; } cout << "S" << endl; int c=1; rep(i,nh) if(c==1&&f[i][now]>0){ cerr << f[i][now] << endl; c=0; f[i][now]-=l/100; if(f[i][now]<=0){ l+=f2[i][now]; score+=f1[i][now]; f[i][now]=f1[i][now]=f2[i][now]=0; } } /* for(int i=nh-1;0<=i;i--){ rep(j,nw) cerr << f[i][j] << " "; cerr << endl; } */ } //cerr << "score : " << score << endl; }