1. 

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #729 The Hamming Distance Problem
* Link: http://uva.onlinejudge.org/external/7/729.pdf
*
* @author Mohr
* @author Schirm
* @author Mathauser
* @version 1.0, 06/08/2009
*
* Status : Accepted
* Runtime: 1.368
*/

import java.io.*;
import java.util.Arrays;

public class Main
{
public static void main(String[]args) throws IOException
{

BufferedReader reader = new BufferedReader(new
InputStreamReader(System.in));
int count = Integer.parseInt(reader.readLine());
reader.readLine();

while(count > 0)
{
String[] line = reader.readLine().split(" ");
if(count > 1)
reader.readLine();
int N = Integer.parseInt(line[0]);
int H = Integer.parseInt(line[1]);
int[] numArray = new int[N];
String output = "";

for(int i = 0; i < H; i++ )
numArray[N-1-i] = 1;


for(int i = 0; i < N; i++)
output += numArray[i];

System.out.println(output);

while(true)
{
output = "";
boolean changed = false;

for(int i = N-1; i > 0; i--)
if(numArray[i]==1 &&
numArray[i-1]==0)
{
numArray[i]=0;
numArray[i-1]=1;
Arrays.sort(numArray, i, N);
changed = true;
break;
}

if(!changed)
break;

for(int i = 0; i < N; i++)
output += numArray[i];


System.out.println(output);
}

if(count > 1)
System.out.println();

count--;
}
}
}