using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TakmicenjeSG
{
    class Program
    {
        static void Main(string[] args)
        {
            int T;
            
            T = int.Parse(Console.ReadLine());
            int[] N = new int[T];
            int[] M = new int[T];
            string[] nebitno = new string[2];
            string unos;
            for (int i = 0; i < T; i++)
            {
                unos = Console.ReadLine();
                nebitno = unos.Split(' ');
                N[i] = int.Parse(nebitno[0]);
                M[i] = int.Parse(nebitno[1]);
            }
            for (int j = 0; j < T; j++)
            {
                if (M[j] == N[j])
                {
                    for (int i = 1; i <= N[j]; i++)
                    {
                        for(int k=1;k<=N[j];k++)
                        {
                            if (k == 1 || k == N[j] || i == 1 || i == N[j] || i + k >= N[j] + 2)
                            {
                                Console.Write("1");
                            }
                            else
                                Console.Write("0");
                        }
                        Console.WriteLine();
                        
                    }
                }
                else
                    Console.WriteLine("-");
                Console.WriteLine();
            }
        }
    }
}