P28599 [洛谷] The Year 2038 Problem
普及+
题目描述

Problem Description

In the era of the internet, opportunities coexist with crises. After the "Millennium Bug" was resolved, could a new "bug" emerge? The answer is affirmative, and "the Year 2038" is a new challenge.

Perhaps everyone is already aware of what the Year 2000 problem for computers entails, but when did the Year 2038 problem arise?

Programs written in C language do not encounter the Year 2000 problem, but they do face the Year 2038 problem. This is because most C language programs use a library called the "standard time library," which stores time information in a standard 4-byte (32-bit) format.

When designed, this 4-byte time format set January 1, 1970, at 00:00:00 as the time origin, with a time value of 0. All subsequent times are accumulated second by second from this point.

For example, if the time has accumulated to the value 919642718, it means that 919642718 seconds have passed since January 1, 1970, at 00:00:00, which translates to February 21, 1999, Sunday, at 16:18:38.

The advantage of this method of time calculation is that by subtracting any two time values, one can quickly determine the number of seconds between these two times, which can then be converted into a comprehensible format of years, months, days, hours, minutes, and seconds.

The maximum value of a 4-byte (32-bit) storage space is 2147483647. Note! The crux of the Year 2038 problem lies here—when the time ticks past the final second of 2147483647, it will turn negative, indicating an invalid time. The exact moment will be January 19, 2038, Tuesday, at 03:14:07, after which all C language programs using this "standard time library" will encounter problems with time calculations.

Your task is to determine, for a given "time origin," what the final valid time is for a computer with a time variable length of N bits.

Input Format

The first line is the number of data sets T.

Lines 2 to T+1 describe each data set with 7 numbers: the length of the time variable (in binary bits), followed by the year, month, day, hour, minute, and second of the "time origin."

Output Format

T lines, for each data set, output 1 line with 6 numbers: the year, month, day, hour, minute, and second of the final valid time.

Sample Input and Output

Input Sample #1

1
16 2000 1 1 0 0 0

Output Sample #1

2000 1 1 9 6 7

Input Sample #2

2
32 1970 1 1 0 0 0
32 2015 11 8 8 30 0

Output Sample #2

2038 1 19 3 14 7
2083 11 26 11 44 7

Notes

For 50% of the data, the number of bits in the variable is <= 16.

For all data, the variable length <= 32, the number of data sets <= 1000, and 0 <= year <= 10000.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 16 2000 1 1 0 0 0
样例输出
2000 1 1 9 6 7