Under construction

Still being built. Things may change

Paint the Map with Stains and Ink

Time limit1sMemory limit1024 MB

Summary
Given K, paint some cells of a 50x50 grid so that the monotone paths from (1,1) to (50,50) avoiding painted cells number exactly K.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, Implementation
Solved
No attempts yet

Problem

Hanbyeol came across this problem while taking a probability and statistics class.

A map is made of 50×5050\times 50 cells. The cell in row ii and column jj is denoted (i,j)(i,j). If one can move from (i,j)(i,j) to (i+1,j)(i+1,j) and to (i,j+1)(i,j+1), how many ways are there to go from (1,1)(1,1) to (50,50)(50,50)?

Hanbyeol thought this problem was too easy, so she wondered whether it would be fun to add stains and ink to some of the cells so that movement is blocked. She asked her friend Dubyeol to write a problem for her. The process is as follows.

  • Dubyeol paints each (i,j)(i,j) (1≤i≤50, 1≤j≤501\le i\le 50,\ 1\le j\le 50) with stain or ink, or leaves it unpainted. Hanbyeol then finds the number of ways to move from (1,1)(1,1) to (50,50)(50,50), where cells painted with stain or ink cannot be entered. If (1,1)(1,1) or (50,50)(50,50) is painted with stain or ink, the number of ways is 0.

Dubyeol wrote several problems for Hanbyeol, but found out that Hanbyeol kept getting the answers wrong. Not wanting her to be upset, Dubyeol used astrology to learn what answer she would give and decided to paint the map to match it. Painting the map to match that answer was not easy. Let us paint the stains and ink on the map in Dubyeol's place!

Input

The first line contains the integer KK, the answer Hanbyeol will say.

Output

Print the map Dubyeol makes as 50 lines, each containing 50 integers separated by spaces. The jj-th integer on the ii-th line is 1 if stain or ink is painted on the cell in the ii-th row from the bottom and the jj-th column from the left, and 0 if nothing is painted there.

The number of ways to reach the destination under the stated conditions for the printed map must be exactly KK.

Constraints

1≤K≤10181\le K\le 10^{18}

Hint

The answer to the original problem is 100891344545564193334812497256100891344545564193334812497256.

Examples1

  1. Example 1

    Input
    2
    
    Expected output
    0 0 0
    1 0 0
    1 1 0