Problem:
Score : 900 points

Problem Statement

We have a grid with (2^N - 1) rows and (2^M-1) columns.
You are asked to write 0 or 1 in each of these squares.
Let a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.

For a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\leq i_1 \leq i_2\leq 2^N-1, 1\leq j_1 \leq j_2\leq 2^M-1, let
S(i_1, i_2, j_1, j_2) = \displaystyle \sum_{r=i_1}^{i_2}\sum_{c=j_1}^{j_2}a_{r,c}.
Then, let the oddness of the grid be the number of quadruples (i_1, i_2, j_1, j_2) such that S(i_1, i_2, j_1, j_2) is odd.

Find a way to fill in the grid that maximizes its oddness.

Constraints

N and M are integers between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N M

Output

Print numbers to write in the grid so that its oddness is maximized, in the following format:

a_{1,1}a_{1,2}\cdots a_{1,2^M-1}
a_{2,1}a_{2,2}\cdots a_{2,2^M-1}
\vdots
a_{2^N-1,1}a_{2^N-1,2}\cdots a_{2^N-1,2^M-1}

If there are multiple solutions, you can print any of them.

Sample Input 1

1 2

Sample Output 1

111

For this grid, S(1, 1, 1, 1), S(1, 1, 2, 2), S(1, 1, 3, 3), and S(1, 1, 1, 3) are odd, so it has the oddness of 4.

We cannot make the oddness 5 or higher, so this is one of the ways that maximize the oddness.

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        /*Experiment(1, 3, 1);
        return;
        for (int i = 1; i < 7; i++)
        {
            Experiment(1, i);
        }*/
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        //Experiment(n, m);
        //return;
        if (n == 1 && m == 1)
        {
            Console.WriteLine(1);
            return;
        }
        var height = (1 << n) - 1;
        var width = (1 << m) - 1;
        int[][] mat = Enumerable.Repeat(0, height).Select(_ => new int[width]).ToArray();
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                mat[i][j] = 1;
            }
        }
        for (int i = 1; i < height; i += 2)
        {
            mat[i][width / 2] = 0;
        }
        for (int i = 1; i < height; i += 2)
        {
            mat[height / 2][i] = 0;
        }

        Console.WriteLine(string.Join("\n", mat.Select(x => string.Join("", x))));
    }
    public static void Experiment(int n, int m, int op = 0)
    {
        var width = (1 << m) - 1;
        var height = (1 << n) - 1;
        var size = width * height;
        int[][] mat = Enumerable.Repeat(0, height).Select(_ => new int[width]).ToArray();
        long max = 0;
        for (long code = 0; code < (1L << (size)); code++)
        {
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if ((code >> (i * width + j) & 1) == 1) mat[i][j] = 1;
                    else mat[i][j] = 0;
                }
            }
            var oddness = CalcOddness(mat);
            if (max < oddness)
            {
                max = oddness;
            }
            //if (max == oddness) Console.WriteLine(string.Join("\n", mat.Select(x => string.Join(" ", x))) + "\n");
        }
        if (op == 0)
        {
            Console.WriteLine($"{max}/{((width + 1) * width / 2) * ((height + 1) * height / 2)}");
            return;
        }
        for (int code = 0; code < (1 << (size)); code++)
        {
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if ((code >> (i * width + j) & 1) == 1) mat[i][j] = 1;
                    else mat[i][j] = 0;
                }
            }
            var oddness = CalcOddness(mat);
            if (max == oddness) Console.WriteLine(string.Join("\n", mat.Select(x => string.Join(" ", x))) + "\n");
        }
        Console.WriteLine(max);
    }
    public static int CalcOddness(int[][] mat)
    {
        var height = mat.Length;
        var width = mat[0].Length;
        int[][] accum = Enumerable.Repeat(0, height + 1).Select(_ => new int[width + 1]).ToArray();
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                accum[i + 1][j + 1] = mat[i][j] + accum[i + 1][j] + accum[i][j + 1] - accum[i][j];
            }
        }
        int res = 0;
        for (int i1 = 0; i1 < height; i1++)
        {
            for (int i2 = i1; i2 < height; i2++)
            {
                for (int j1 = 0; j1 < width; j1++)
                {
                    for (int j2 = j1; j2 < width; j2++)
                    {
                        if ((accum[i2 + 1][j2 + 1] - accum[i1][j2 + 1] - accum[i2 + 1][j1] + accum[i1][j1] & 1) == 1)
                            res++;
                    }
                }
            }
        }
        return res;
    }
}