It is the 23rd century. Humans have finally colonized several nearby solar systems and dwell happily in their planets. Space travel is anyway very expensive and most inhabitants of extraterrestrial planets never again leave the surface of their planet in their lifetimes. Thus, upon arrival to an uninhabited planet, the colonizers adjusted the traditional Earth system of keeping track of time to the specific situation of that planet, in a way it would be practical for that planet and at the same time similar to what they were accustomed to. In most planets, colonizers split the duration of a day into m hours (of duration similar to that of Earth’s hours) and split each of those hours into n minutes. They read time from clocks in which the hour-hand moves continuously at a steady rate of one revolution per day, and the minute-hand moves continuously at a steady rate of one revolution per hour; the day begins at 0h : 0min at which time both hands are pointing upwards. An interstellar clock manufacturer came up with a revolutionary clock design in which both the hour-hand and the minute-hand are the same size! They figured you could anyway tell the correct time from the clock. For instance, assume that in a 12-hour clock (like those on Earth) one of the hands is pointing upwards (to the 12) and the other hand is pointing to the 3: we can be sure it is 3 o’clock because it is impossible that the hour-hand is exactly pointing to the 12 and the minute-hand is not also pointing to the 12. Therefore we know it is the hour-hand that is pointing to the 3 and from this we can tell the time. However, users from some planets soon complained they were having trouble telling the time from certain positions of the hands. The clock manufacturer has hired you to write a program to determine how many times during a certain time period confusion may arise from the position of the clock hands. Input The input consists of several test cases. The first line of each case contains three positive integers m, n and nq, where m and n represent the number of hours in a day and the number of minutes in an hour for a certain planet, and nq is the number of queries that follow. You may assume m,n,nq ≤ 1000. Each query is contained in a separate line and contains two times of the day, t1 and t2, separated by a space. Each time of the day is given in the following format: h:min num/den where h is the hours, min is the minutes and num/den is a fraction < 1 which corresponds to a fraction of a minute. For example, in Earth time, ‘3:30 1/2’ would correspond to 3 hours, thirty minutes and 30seconds(halfaminute). Youmayassumethat0≤h<m,0≤min<n,0≤num,den≤1000and that t1 ≤ t2 (this means that, within a day, t1 does not happen after t2). Input is terminated when m = n = nq = 0, this case should not be processed. Output For each test case print the header ‘Planet i:’, without quotes, where i indicates the test case number (beginning from 1) and then print, for each query, a line with a non-negative integer indicating the number of occasions in which confusion may arise from the position of the clock hands during the time interval (t1,t2]. If there are an infinite number of such occasions, print ‘Infinity’, without quotes, instead of a number. Separate output from different test cases by a blank line.

2/2 Sample Input 12 60 2 11:0 0/1 11:0 0/1 6:45 1/3 7:1 2/5 000 Sample Output Planet 1: 0 3