#include"string.h"
#include"iostream"
using namespace std;
const int M=41111;
int f[M];
struct st
{
int x,y;
}node[M];
int finde(int x,int L,char ch)
{
if(x!=f[x])
{
int t=f[x];
f[x]=finde(f[x],L,ch);
//printf("-->%d %d ",t,x);
if(ch=='E')
{
node[x].x=node[x].x+L;
node[x].y=node[x].y;
}
else if(ch=='W')
{
node[x].x=node[x].x-L;
node[x].y=node[x].y;
}
else if(ch=='N')
{
node[x].x=node[x].x;
node[x].y=node[x].y+L;
}
else if(ch=='S')
{
node[x].x=node[x].x;
node[x].y=node[x].y-L;
}
}
return f[x];
}
void make(int a,int b,int L,char ch)
{
int x=finde(a,L,ch);
int y=finde(b,L,ch);
if(x!=y)
{
f[y]=x;
if(ch=='E')
{
node[y].x=node[x].x+L;
node[y].y=node[x].y;
}
else if(ch=='W')
{
node[y].x=node[x].x-L;
node[y].y=node[x].y;
}
else if(ch=='N')
{
node[y].x=node[x].x;
node[y].y=node[x].y+L;
}
else if(ch=='S')
{
node[y].x=node[x].x;
node[y].y=node[x].y-L;
}
}
}
int main()
{
int i,m,n,a,b,L;
char ch[3];
while(scanf("%d%d",&n,&m)!=-1)
{
for(i=1;i<=n;i++)
f[i]=i;
while(m--)
{
scanf("%d%d%d%s",&a,&b,&L,ch);
make(a,b,L,ch[0]);
}
for(i=1;i<=n;i++)
printf("%d %d ",node[i].x,node[i].y);
}
return 0;
}