let pi = 4.0 *. atan 1.0;;
let to_radians x = x *. pi /. 180.;;
let split_float s = Str.split (Str.regexp_string ",") s
                    |> List.map float_of_string;;
let () =
  let rec read x y turn =
    let nth = read_line () |> split_float |> List.nth in
    let (d, t) = (nth 0, nth 1) in
    (
      match (d, t) with
        (0., 0.) -> (x, y)
      | (d, t) ->
         read (x +. (d *. (cos (to_radians turn)))) (y +. ((d *. sin (to_radians turn)))) (turn -. t))
  in
  let (x, y) = read 0. 0. 90. in
  Printf.printf "%d\n%d\n" (int_of_float x) (int_of_float y);;