import math

x = y = 0

theta = 90

while True:

    d, a = list(map(int, input().split(',')))

    if d==a==0:

        break

    x += d * math.cos(theta * math.pi / 180)

    y += d * math.sin(theta * math.pi / 180)

    theta -= a

print((int(x)))

print((int(y)))
import math

x = y = 0

ang = 90

while True:

    d, a = list(map(int, input().split(',')))

    if d == a == 0:

        break

    rad = ang * math.pi / 180

    x += d * math.cos(rad)

    y += d * math.sin(rad)

    ang -= a

print((int(x)))

print((int(y)))

import math

x = y = 0
theta = 90
while True:
    d, a = list(map(int, input().split(",")))
    if d == a == 0:
        break
    x += d * math.cos(theta * math.pi / 180)
    y += d * math.sin(theta * math.pi / 180)
    theta -= a
print((int(x)))
print((int(y)))

import math

x = y = 0
ang = 90
while True:
    d, a = list(map(int, input().split(",")))
    if d == a == 0:
        break
    rad = ang * math.pi / 180
    x += d * math.cos(rad)
    y += d * math.sin(rad)
    ang -= a
print((int(x)))
print((int(y)))

-theta = 90 +ang = 90 -    x += d * math.cos(theta * math.pi / 180) -    y += d * math.sin(theta * math.pi / 180) -    theta -= a +    rad = ang * math.pi / 180 +    x += d * math.cos(rad) +    y += d * math.sin(rad) +    ang -= a