//way题解
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long n;
long long fx,x,y,shu,bj;
string s;
int main(){
//freopen("way.in","r",stdin);
//freopen("way.out","w",stdout);
scanf("%lld",&n);
for(int i=0;i<n;i++){
cin>>s;
if(s[0]=='l'){
fx--;
if(fx==-1){
fx=3;
}
}
else if(s[0]=='r'){
fx++;
if(fx==4){
fx=0;
}
}else{
bj=1;
shu=0;
for(int j=0;j<s.length();j++){
shu*=10;
shu+=s[j]-'0';
}
if(fx==0){//改变方向
y+=shu;
}
if(fx==1){
x+=shu;
}
if(fx==2){
y-=shu;
}
if(fx==3){
x-=shu;
}
printf("(%lld,%lld)
",x,y);
}
}
if(bj==0){
cout<<"(0,0)"<<endl;
}
return 0;
}