Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kalendar-qatori-va-ustuni

Calendar row and column

Medium 1000 ms 64 MB 37%
Share

A month's calendar is written as a table: each row has $7$ columns, column $1$ is Monday, …, column $7$ is Sunday. Day $1$ of the month falls on day $d$ of the week and is written in column $d$ of row $1$; the following days continue along that row, and when the row ends they continue from column $1$ of the next row. Find the row and the column of day $k$.

A month calendar table: day 1 is in column d; the row and column of day k are found

Input

One line with two positive integers: $d$ and $k$.

Output

One line with two positive integers: the row number and the column number.

Note

$1 \le d \le 7$
$1 \le k \le 31$

Examples

Input #1
3 17
Output #1
3 5
Input #2
7 1
Output #2
1 7

Sign in to submit a solution

Signing up is free and takes a minute.