type pos = {east:float;north:float;angle:float}

let _ = 
  let round x = int_of_float @@ if x > 0.0 then floor x else ceil x in
  let to_rad x =
    let pi = 3.14159265358979 in
    x *. pi /. 180.0 in
  let move p d a = 
    {east = p.east +. d *. cos (to_rad p.angle);
     north = p.north +. d *. sin (to_rad p.angle);
     angle = p.angle -. a} in
  let rec iter p =
    let d,a = Scanf.scanf "%f,%f\n" (fun d a -> (d, a)) in
    if d = 0.0 && a = 0.0 then Printf.printf "%d\n%d\n" (round p.east) (round p.north)
    else iter @@ move p d a in
  iter {east = 0.0; north = 0.0; angle = 90.0}