In Byteland lives a clockmaker named Gustaw, who has repaired clocks for many years. His workshop is full of old clocks, and every one of them is an analog clock that shows the time with hands. Each clock has two hands: a byte-hour hand and a byte-minute hand, and both hands only ever move forward (clockwise).
In Byteland one byte-hour always lasts exactly 100 byte-minutes, so every clock has a minute scale divided into 100 byte-minutes. However, the length of a day in Byteland has changed many times over the years, so the clocks do not all have the same number of byte-hours on their dials. The dial of clock i is divided into pi byte-hours, numbered 0 through pi−1.
The king is about to visit, and Gustaw wants to make the best possible impression, so he decides that every clock should show the exact same time. Right now every clock is stopped. Because the clocks are very old and could break, Gustaw must not turn the hands by hand. Instead he may pick any single clock, start it, let it run forward by as many byte-hours and byte-minutes as he likes, and then stop it. He can never run two clocks at the same time, so he must set them one after another, and the times he waits for each clock all add up.
Gustaw picks one target time that every clock is able to display: a whole byte-hour H together with a byte-minute M (with 0≤M<100). Because the dial of clock i only carries the byte-hours 0,1,…,pi−1, the target byte-hour must satisfy 0≤H<pi for every clock. He then runs each clock forward from its current reading to that target time. Since the hands only move forward, a clock whose current position is c byte-minutes (where c=100⋅gi+mi) must run forward by (H⋅100+M−c)mod(pi⋅100) byte-minutes.
Help Gustaw choose the target byte-hour and byte-minute so that the total time he spends running the clocks is as small as possible, and report that minimum total time.
The first line contains one integer n (1≤n≤106), the number of clocks. Each of the next n lines describes one clock with three integers gi, mi, pi: the byte-hour currently shown by clock i, the byte-minute currently shown, and the number of byte-hours on that clock's dial (0≤gi<pi≤109 and 0≤mi<100).
Print one line with two integers: the number of byte-hours and the number of byte-minutes that Gustaw must wait in total when he uses the smallest possible total time. (A total of t byte-minutes is written as ⌊t/100⌋ byte-hours and tmod100 byte-minutes.)