Codeforces Round 372 (Div. 1)
D
Create a Maze
Codeforces
3100
原题
← CE →
翻译中…

ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of $*n* × *m*$ rooms, and the rooms are arranged in $*n*$ rows (numbered from the top to the bottom starting from $1$) and $*m*$ columns (numbered from the left to the right starting from $1$). The room in the $*i*$-th row and $*j*$-th column is denoted by $(*i*, *j*)$. A player starts in the room $(1, 1)$ and wants to reach the room $(*n*, *m*)$.

翻译中…

Each room has four doors (except for ones at the maze border), one on each of its walls, and two adjacent by the wall rooms shares the same door. Some of the doors are locked, which means it is impossible to pass through the door. For example, if the door connecting $(*i*, *j*)$ and $(*i*, *j* + 1)$ is locked, then we can't go from $(*i*, *j*)$ to $(*i*, *j* + 1)$. Also, one can only travel between the rooms downwards (from the room $(*i*, *j*)$ to the room $(*i* + 1, *j*)$) or rightwards (from the room $(*i*, *j*)$ to the room $(*i*, *j* + 1)$) provided the corresponding door is not locked.

翻译中…

image This image represents a maze with some doors locked. The colored arrows denotes all the possible paths while a red cross denotes a locked door.

翻译中…

ZS the Coder considers a maze to have difficulty $*x*$ if there is exactly $*x*$ ways of travelling from the room $(1, 1)$ to the room $(*n*, *m*)$. Two ways are considered different if they differ by the sequence of rooms visited while travelling.

翻译中…

Your task is to create a maze such that its difficulty is exactly equal to $*T*$. In addition, ZS the Coder doesn't like large mazes, so the size of the maze and the number of locked doors are limited. Sounds simple enough, right?

翻译中…

Input

翻译中…

The first and only line of the input contains a single integer $*T*$ ($1 ≤ *T* ≤ 10^{18}$), the difficulty of the required maze.

翻译中…

Output

翻译中…

The first line should contain two integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 50$) — the number of rows and columns of the maze respectively.

翻译中…

The next line should contain a single integer $*k*$ ($0 ≤ *k* ≤ 300$) — the number of locked doors in the maze.

翻译中…

Then, $*k*$ lines describing locked doors should follow. Each of them should contain four integers, $*x*_{1}, *y*_{1}, *x*_{2}, *y*_{2}$. This means that the door connecting room $(*x*_{1}, *y*_{1})$ and room $(*x*_{2}, *y*_{2})$ is locked. Note that room $(*x*_{2}, *y*_{2})$ should be adjacent either to the right or to the bottom of $(*x*_{1}, *y*_{1})$, i.e. $*x*_{2} + *y*_{2}$ should be equal to $*x*_{1} + *y*_{1} + 1$. There should not be a locked door that appears twice in the list.

翻译中…

It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them.

翻译中…

Note

翻译中…

Here are how the sample input and output looks like. The colored arrows denotes all the possible paths while a red cross denotes a locked door.

翻译中…

In the first sample case:

翻译中…

image

翻译中…

In the second sample case:

翻译中…

image

翻译中…

样例

Input #1
3
Output #1
3 2
0
InputCopy OutputCopy
Input #2
4
Output #2
4 3
3
1 2 2 2
3 2 3 3
1 3 2 3
InputCopy OutputCopy
题目信息
题号
715D
时间限制
2 s
内存限制
256 MB
标签
构造

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。