A - Time Normalization Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

高橋君は、料理教室の予約管理システムを開発しています。このシステムでは、各予約の開始時刻を時と分の組で管理しています。

しかし、入力フォームの不具合により、分の値が 60 以上になっていたり、時の値が 24 以上になっていたりする不正なデータが登録されてしまうことがあります。例えば、2580 分のような時刻データが存在します。

高橋君は、これらの不正な時刻データを正規化するプログラムを作成することにしました。正規化とは、与えられた時刻データ(時 H、分 M)を、ある日の 00 分を基準としてちょうど (60H + M) 分が経過した時刻とみなし、「D 日後の hm 分」(ただし 0 \leq h \leq 230 \leq m \leq 59D \geq 0)の形に変換することです。

正規化の計算は以下の手順で行えます。手順 1、手順 2 の順に実行してください。

  1. 分の繰り上げ: 分の値 M60= 1 時間として時に繰り上げます。具体的には、繰り上げ後の時の値を H' = H + \lfloor M / 60 \rfloor、正規化後の分の値を m = M \bmod 60 とします。
  2. 時の繰り上げ: 手順 1 で得た時の値 H'24 時間 = 1 日として日数に繰り上げます。具体的には、正規化後の日数を D = \lfloor H' / 24 \rfloor、正規化後の時の値を h = H' \bmod 24 とします。

以上により、正規化後の日数 DD = 0 は基準日の当日を意味します)、時 h0 \leq h \leq 23)、分 m0 \leq m \leq 59)が定まります。

N 件の予約の開始時刻データが与えられるので、それぞれを正規化し、正規化後の日数 D、時 h、分 m を出力してください。

制約

  • 1 \leq N \leq 10^5
  • 0 \leq H_i \leq 10^9
  • 0 \leq M_i \leq 10^9
  • 入力はすべて整数である。

入力

N
H_1 M_1
H_2 M_2
\vdots
H_N M_N

1 行目には、予約の件数を表す整数 N が与えられます。続く N 行のうち i 行目 (1 \leq i \leq N) には、i 番目の予約の時を表す整数 H_i と分を表す整数 M_i が、スペース区切りで与えられます。

出力

N 行出力してください。i 行目には、i 番目の予約データ (H_i, M_i) に対して上記の正規化を行って得られる日数 D_i、時 h_i、分 m_i を、スペース区切りで出力してください。


入力例 1

3
10 30
25 80
0 90

出力例 1

0 10 30
1 2 20
0 1 30

入力例 2

4
23 59
24 0
0 1440
48 120

出力例 2

0 23 59
1 0 0
1 0 0
2 2 0

入力例 3

8
0 0
12 30
23 59
24 60
100 200
0 1500
50 0
47 61

出力例 3

0 0 0
0 12 30
0 23 59
1 1 0
4 7 20
1 1 0
2 2 0
2 0 1

入力例 4

15
0 0
1 0
0 1
23 59
24 0
24 1
0 60
25 80
100 100
999 999
10000 10000
123456 789012
1000000000 1000000000
999999999 999999999
500000000 500000000

出力例 4

0 0 0
0 1 0
0 0 1
0 23 59
1 0 0
1 0 1
0 1 0
1 2 20
4 5 40
42 7 39
423 14 40
5691 22 12
42361111 2 40
42361111 1 39
21180555 13 20

入力例 5

1
0 0

出力例 5

0 0 0

Score : 200 pts

Problem Statement

Takahashi is developing a reservation management system for a cooking class. In this system, the start time of each reservation is managed as a pair of hours and minutes.

However, due to a bug in the input form, invalid data may be registered where the minute value is 60 or greater, or the hour value is 24 or greater. For example, time data such as 25 hours 80 minutes may exist.

Takahashi decided to create a program to normalize these invalid time data. Normalization means treating the given time data (hours H, minutes M) as the time exactly (60H + M) minutes after 0 hours 0 minutes of a certain day, and converting it into the form "D days later, h hours m minutes" (where 0 \leq h \leq 23, 0 \leq m \leq 59, D \geq 0).

The normalization calculation can be performed by the following steps. Execute Step 1, then Step 2, in order.

  1. Carry-over of minutes: Carry over the minute value M into hours, using 60 minutes = 1 hour. Specifically, the hour value after carry-over is H' = H + \lfloor M / 60 \rfloor, and the normalized minute value is m = M \bmod 60.
  2. Carry-over of hours: Carry over the hour value H' obtained in Step 1 into days, using 24 hours = 1 day. Specifically, the normalized number of days is D = \lfloor H' / 24 \rfloor, and the normalized hour value is h = H' \bmod 24.

Through the above, the normalized number of days D (D = 0 means the reference day itself), hours h (0 \leq h \leq 23), and minutes m (0 \leq m \leq 59) are determined.

Given the start time data of N reservations, normalize each of them and output the normalized number of days D, hours h, and minutes m.

Constraints

  • 1 \leq N \leq 10^5
  • 0 \leq H_i \leq 10^9
  • 0 \leq M_i \leq 10^9
  • All input values are integers.

Input

N
H_1 M_1
H_2 M_2
\vdots
H_N M_N

The first line contains an integer N representing the number of reservations. Of the following N lines, the i-th line (1 \leq i \leq N) contains an integer H_i representing the hours and an integer M_i representing the minutes of the i-th reservation, separated by a space.

Output

Output N lines. On the i-th line, output the number of days D_i, hours h_i, and minutes m_i obtained by performing the above normalization on the i-th reservation data (H_i, M_i), separated by spaces.


Sample Input 1

3
10 30
25 80
0 90

Sample Output 1

0 10 30
1 2 20
0 1 30

Sample Input 2

4
23 59
24 0
0 1440
48 120

Sample Output 2

0 23 59
1 0 0
1 0 0
2 2 0

Sample Input 3

8
0 0
12 30
23 59
24 60
100 200
0 1500
50 0
47 61

Sample Output 3

0 0 0
0 12 30
0 23 59
1 1 0
4 7 20
1 1 0
2 2 0
2 0 1

Sample Input 4

15
0 0
1 0
0 1
23 59
24 0
24 1
0 60
25 80
100 100
999 999
10000 10000
123456 789012
1000000000 1000000000
999999999 999999999
500000000 500000000

Sample Output 4

0 0 0
0 1 0
0 0 1
0 23 59
1 0 0
1 0 1
0 1 0
1 2 20
4 5 40
42 7 39
423 14 40
5691 22 12
42361111 2 40
42361111 1 39
21180555 13 20

Sample Input 5

1
0 0

Sample Output 5

0 0 0