Title: Treasure Hunt

When a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from "Sanbonmatsu," one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.

For simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.

Constraints: d ≤ 100, -180 ≤ t ≤ 180.

Input:
A sequence of pairs of integers d and t, ending with "0,0".

Output:
Print the integer portion of x and y in a line respectively.

Sample Input:
56,65
97,54
64,-4
55,76
42,-27
43,80
87,-86
55,-6
89,34
95,5
0,0

Output for the Sample Input:
171
-302

# Buggy version:
import math
x=0
y=0
angle=0
while True:
    r,c=map(int, input().split(","))
    if r == c == 0:
        break

    x += r*math.cos(-angle)
    y += r*math.sin(-angle)
    angle += c

print(x)
print(y)

# Fixed version:
import math
x=0
y=0
angle=0
while True:
    r,c=map(int, input().split(","))
    if r == c == 0:
        break

    y += r*math.cos(angle)
    x += r*math.sin(angle)
    angle -= c*math.pi/180


print(int(-x))
print(int(y))

# Buggy version:
import math
x,y,r = 0,0,90
while True:
  m,n = map(int,raw_input().split(','))
  if (m,n) == (0,0):
    break
  y += m * math.sin(math.radians(r))
  y
  x+= m * math.cos(math.radians(r))
  r -= n
print(int(x))
print(int(y))

# Fixed version:
import math
x,y,r = 0,0,90
while True:
  m,n = map(int,input().split(','))
  if (m,n) == (0,0):
    break
  y += m * math.sin(math.radians(r))
  x += m * math.cos(math.radians(r))
  r -= n
print(int(x))
print(int(y))

# Buggy version:
import math

x, y, r = 0, 0, 90
while True:
    d, t = map(float, input().split(","))
    if d == t == 0:
        break
    x += r * math.cos(math.radians(r))
    y += r * math.sin(math.radians(r))
    r -= t
print(int(x))
print(int(y))

# Fixed version:
import math

x, y, r = 0, 0, 90
while True:
    d, t = map(float, input().split(","))
    if d == t == 0:
        break
    x += d * math.cos(math.radians(r))
    y += d * math.sin(math.radians(r))
    r -= t
print(int(x))
print(int(y))

# Buggy version:
import math
x = 0
y = 0
r = 90
while True:
    d,t=map(int, input().split())
    if d==0 and t==0:
        print(int(x),int(y),sep='\n')
        exit()
    x += math.cos(math.radians(r)) * d
    y += math.sin(math.radians(r)) * d
    r -= t

# Fixed version:
import math
x = 0
y = 0
r = 90
while True:
    d,t=map(int, input().split(','))
    if d==0 and t==0:
        print(int(x),int(y),sep='\n')
        exit()
    x += math.cos(math.radians(r)) * d
    y += math.sin(math.radians(r)) * d
    r -= t

# Buggy version:
import math

def calc(x, y, r, d, nd):
	x = x + r * math.cos(math.radians(d))
	y = y + r * math.sin(math.radians(d))
	d -= nd
	return x, y, d

x = y = 0
d = 90

while True:
	r, nd = map(int, input().split(","))
	if r == nd == 0: break
	x, y, d = calc(x, y, r, d, nd)

print(int(x), "\n", int(y))

# Fixed version:
import math

def calc(x, y, r, d, nd):
	x = x + r * math.cos(math.radians(d))
	y = y + r * math.sin(math.radians(d))
	d -= nd
	return x, y, d

x = y = 0
d = 90

while True:
	r, nd = map(int, input().split(","))
	if r == nd == 0: break
	x, y, d = calc(x, y, r, d, nd)

print(int(x))
print(int(y))

# Buggy version:
from math import sin,cos,pi
x = 0
y = 0
ca = 90
while True:
    d, a = list(map(int, input().split(",")))
    if d or a:
        x += d*cos(ca*pi/180)
        y += d*sin(ca*pi/180)
        ca -= a
    else:
        break

print("{0:.0f}".format(x))
print("{0:.0f}".format(y))

# Fixed version:
from math import sin,cos,pi
x = 0
y = 0
ca = 90
while True:
    d, a = list(map(int, input().split(",")))
    if d or a:
        x += d*cos(ca*pi/180)
        y += d*sin(ca*pi/180)
        ca -= a
    else:
        break

print(int(x))
print(int(y))

# Buggy version:
import sys
import math as mas

x,y,d=0,0,90
for t in sys.stdin:
	a,b=map(int,t.split(','))
	if a==b==0:break
	x+=a*mas.cos(mas.radians(d))
	y+=a*mas.sin(mas.radians(d))
	d-=b
print(x)
print(y)
#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

# Fixed version:
import sys
import math as mas

x,y,d=0,0,90
for t in sys.stdin:
	a,b=map(int,t.split(','))
	if a==b==0:break
	x+=a*mas.cos(mas.radians(d))
	y+=a*mas.sin(mas.radians(d))
	d-=b
print(int(x))
print(int(y))
#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

# Buggy version:
from math import *

x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(sum_a * pi / 180)
    y = y - D[i] * sin(sum_a * pi / 180)
    if abs(x-round(x))<10**(-7):
        x=round(x)
    if abs(y - round(y)) < 10 ** (-7):
        y=round(y)
    sum_a += A[i]
print(floor(x))
print(floor(y))

# Fixed version:
from math import *

x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(sum_a * pi / 180)
    y = y - D[i] * sin(sum_a * pi / 180)
    if abs(x-round(x))<10**(-7):
        x=round(x)
    if abs(y - round(y)) < 10 ** (-7):
        y=round(y)
    sum_a += A[i]
if x >= 0:
    print(floor(x))
else:
    print(floor(x)+1)
if y >= 0:
    print(floor(y))
else:
    print(floor(y)+1)

# Buggy version:
import sys
import math

def TreasureHunt():
    x,y=(0.0,0.0)
    alpha=90
    
    for line in sys.stdin:
        a,b=list(map(int,line.split(',')))
        if a==0 and b==0:
            break
        
        x+=a*math.cos(alpha/180.0*math.pi)
        y+=a*math.sin(alpha/180.0*math.pi)
        alpha=(alpha-b+360)%360

    print(int(x),'\n',int(y))

        
        
            
TreasureHunt()

# Fixed version:
import sys
import math

def TreasureHunt():
    x,y=(0.0,0.0)
    alpha=90
    
    for line in sys.stdin:
        a,b=list(map(int,line.split(',')))
        if a==0 and b==0:
            break
        
        x+=a*math.cos(alpha/180.0*math.pi)
        y+=a*math.sin(alpha/180.0*math.pi)
        alpha=(alpha-b+360)%360

    print(int(x))
    print(int(y))

        
        
            
TreasureHunt()

# Buggy version:
from math import cos, sin, pi

treasure_x, treasure_y = 0, 0
angle = pi / 2

while True:
    d, a = map(int, input().split(','))

    if d == 0 and a == 0:
        break

    treasure_x += d * cos(angle)
    treasure_y += d * sin(angle)

    angle += a * 2 * pi / 180


print(int(treasure_x))
print(int(treasure_y))

# Fixed version:
from math import cos, sin, pi

treasure_x, treasure_y = 0, 0
angle = pi / 2

while True:
    d, a = map(int, input().split(','))

    if d == 0 and a == 0:
        break

    treasure_x += d * cos(angle)
    treasure_y += d * sin(angle)

    angle -= a * pi / 180

print(int(treasure_x))
print(int(treasure_y))

# Buggy version:
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real),'\n',int(z.imag))


# Fixed version:
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real),'\n',int(z.imag),sep='')

# Buggy version:
import math
x = y = n= 0
while True:
	d,a = map(int,input().split(','))
	if d == a == 0: break
	x += d*math.sin(math.radians(n))
	y += d*math.cos(math.radians(n))
	n+=a
print(*map(int,(x,y)),sep=',')


# Fixed version:
import math
x = y = n= 0
while True:
	d,a = map(int,input().split(','))
	if d == a == 0: break
	x += d*math.sin(math.radians(n))
	y += d*math.cos(math.radians(n))
	n+=a
print(*map(int,(x,y)),sep='\n')

# Buggy version:
import math
x = y = 0
h = math.radians(90)
while True:
    d, t = map(int, input().split(","))
    if d == t == 0:
        break
    x += d * math.cos(h)
    y += d * math.sin(h)
    h -= math.radians(t)
print("{} {}".format(int(x), int(y)))


# Fixed version:
import math
x = y = 0
h = math.radians(90)
while True:
    d, t = map(int, input().split(","))
    if d == t == 0:
        break
    x += d * math.cos(h)
    y += d * math.sin(h)
    h -= math.radians(t)
print(int(x))
print(int(y))

# Buggy version:
from math import radians
from cmath import rect

z = 0
deg = 90
while True:
    r, d = map(float, input().split(','))
    if r == d == 0: break
    z += rect(r, radians(deg))
    deg -= d
print(int(z.real), int(z.imag))

# Fixed version:
from math import radians
from cmath import rect

z = 0
deg = 90
while True:
    r, d = map(float, input().split(','))
    if r == d == 0: break
    z += rect(r, radians(deg))
    deg -= d
print(int(z.real))
print(int(z.imag))