#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 60;

/* typedef */

typedef long long ll;

/* global variables */

int n;
ll m;
ll combs[MAX_N + 1][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  memset(combs, 0, sizeof(combs));
  combs[0][0] = 1;
  for (int i = 1; i <= MAX_N; i++) {
    combs[i][0] = 1;
    for (int j = 1; j <= MAX_N; j++)
      combs[i][j] = combs[i - 1][j] + combs[i - 1][j - 1];
  }

  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    m--;
    
    int k;
    for (k = 0; m >= combs[n][k]; k++)
      m -= combs[n][k];
    //printf("k=%d, m=%lld\n", k, m);

    string bits;

    while (n > 0) {
      if (m < combs[n - 1][k]) {
	bits += '0';
      }
      else {
	bits += '1';
	m -= combs[n - 1][k];
	k--;
      }
      n--;
    }

    cout << bits << endl;
  }
  
  return 0;
}