#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll comb[99][99];

int main(){
  comb[0][0] = 1;
  for(int i=1;i<=60;i++){
    comb[i][0] = comb[i][i] = 1;
    for(int j=1;j<i;j++)comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  }

  ll n,m;
  while(cin >> n >> m, n){
    m--;
    int k = 0;
    while(comb[n][k]<=m)m -= comb[n][k++];

    string res = "";
    for(int i=0;i<n;i++){
      int rem = n-i-1;
      if(comb[rem][k]<=m){
	m -= comb[rem][k--];
	res += "1";
      }else res += "0";
    }
    cout << res << endl;
  }
}