Margaret's Minute Minute Manipulation

No attempts yetTime limit1sMemory limit256 MB

Problem

Margaret is good at maths. In her free time she tries to apply the principles of binary quantum refraction to time travel. She encodes a time of day in binary and adds a non negative time difference δ\delta to it, hoping to create a singularity in the fabric of space and time that lets a traveller jump δ\delta into the future.

A time of day is usually written in the 24 hour format, for example 03:14:15. There are several ways to write a time in binary. This problem uses the one below.

Figure 1. The binary clock format of the time 03:14:15.

One 4×64 \times 6 matrix holds one time of day. Each of the six decimal digits of the 24 hour format is encoded separately in 4 bits, written down a single column with the most significant bit on top and the least significant bit at the bottom. For example the decimal digit 3 is 0011 in 4 bit binary, because (0×23)+(0×22)+(1×21)+(1×20)=3(0 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 3.

Given a time of day TT and a time difference δ\delta, both in the binary clock format, compute the time of day T+δT + \delta. The result is again a time of day, so a sum that reaches 24 hours continues from 00:00:00.

Input

The input has 8 lines. Each line holds 6 bits separated by single spaces. The first 4 lines are the binary clock matrix of the time of day TT, and the next 4 lines are the matrix of the time difference δ\delta. Both matrices encode a valid time from 00:00:00 to 23:59:59 inclusive. Time is treated naively here: time zones, leap seconds and daylight saving shifts are ignored.

Output

Print the time T+δT + \delta in the 4×64 \times 6 binary clock format: 4 lines, each holding 6 bits separated by single spaces. If the sum reaches or passes 24 hours, subtract 24 hours until the result is a time of day from 00:00:00 to 23:59:59. End the last line with a newline.