#33041: cppcccccccccccccccccccccccccccc333333333333333333333333311111111111111111111111111155555555555555555


yp11151025@yphs.tp.edu.tw (803-23江紘宇)


#include<iostream>
using namespace std;
int main(){
    int n,a,b,x=0,y=0;
    cin>>n;
    while(n--){
        cin>>a>>b;
        switch(a){
            case 0: y+=b; break;
            case 1: x+=b; break;
            case 2: y-=b; break;
            case 3: x-=b; break;
        }
    }
    cout<<x<<" "<<y<<"\n";
}