#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct wave
{
int v,d;
char dir;
};
int get_index(char ch)
{
if(ch=='W')
{
return 0;
}
else if(ch=='S')
{
return 1;
}
else if(ch=='E')
{
return 2;
}
else if(ch=='N')
{
return 3;
}
}
bool gt(wave a,wave b)
{
long long ra,rb;
ra=a.d*b.v;
rb=b.d*a.v;
if(ra!=rb)
{
return ra<rb;
}
return get_index(a.dir)<get_index(b.dir);
}
int main()
{
int n,c;
vector <wave> v;
wave temp;
while(cin>>n)
{
v.clear();
while(n--)
{
cin>>temp.dir>>temp.d>>temp.v;
v.push_back(temp);
}
sort(v.begin(),v.end(),gt);
for(int i=0;i<v.size();++i)
{
cout<<v[i].dir;
}
cout<<endl;
}
}
long long ra,rb;
ra=a.d*b.v;
rb=b.d*a.v;
先轉long long再乘