import std.stdio, std.string, std.conv, std.math;

void main(){
    real x = 0, y = 0, rad = 90;
    while(true){
        auto line = readln.chomp.split(",");
        auto speed = line[0].to!int;
        if(speed == 0) break;
        x += cos(rad / 180 * PI) * speed;
        y += sin(rad / 180 * PI) * speed;
        rad -= line[1].to!int;
    }
    writeln(cast(int)x);
    writeln(cast(int)y);
}