K repeated 1s
Difficulty: Hard

One day Sanchit decided to write all numbers starting from 1 in binary format. The list goes like this 1,10,11,100,... and so on. Now he gets bored of this list and decides to remove all the numbers having atleast k consecutive ones and prepare a new list. He then thought if a number n is given to him can he find the nth member of the new list. After trying for some time he comes to you for help. Can you help him by writing a program for him that coud do the specified task.

**Constraints**

2<=K<=10

1<=T<=1000

1<=n<=10<sup>15</sup>

Input Format:
First line of each input is T and k separated by spaces where T is number of test cases and k is explained above. T lines folow. Each line contains one number n.

Output Format:
You have to output n<sup>th</sup> binary number for each case. Each case must be in a new line. 

Sample Input:
	5 2
	1
    2
    3
    4
    5

Sample Output:
    1
    10
    100
    101
    1000

Python 3 starter code:


Reference solution (C++):
    #include<stdio.h>

    int main()
    {
        int t,k,p,l;
        long long int n,i,j;
        long long int a[2001],ans[2001];
        scanf("%d %d",&t,&k);
        p=0;
        l=1;
        while(p<k)
        {
            a[p]=l;
            l*=2;
            p++;
        }
        for(i=k;i<2000;i++)
        {
            p=1;
            a[i]=0;
            while(p<=k)
            {
                a[i]+=a[i-p];
                p++;
            }
            if(a[i]>(long long)1000000000000000) break;
        }
        while(t--)
        {
            scanf("%lld",&n);
            for(i=0;;i++)
            {
                if(a[i]>n) break;
            }
            j=0;
            while(i>0)
            {
                ans[j]=n/a[i-1];
                n=n%a[i-1];
                j++;
                i--;
            }
            for(i=0;i<j;i++)
            printf("%lld",ans[i]);
            printf("\n");
        }
        return 0;
    }