#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1LL<<63)
#define MAX 70
#define deb(a) cout << #a << " " << a << endl

using namespace std;

typedef long long ll;

ll N,M;
ll C[MAX][MAX];

void makeC()
{
  C[0][0] = 1;
  rep(i,MAX-1)rep(j,i+1)
    {
      C[i+1][j] += C[i][j];
      if(j+1<MAX)C[i+1][j+1] += C[i][j];
    }
}

void compute()
{
  M--;
  if(M == 0)
    {
      cout << string(N,'0') << endl;
      return;
    }
  string ans = "";
  int NumberOfBits = 1;
  ll sum = 0;
  while(true)
    {
      sum += C[N][NumberOfBits]; 
      if(sum >= M)break;
      NumberOfBits++;
    }
  sum -= C[N][NumberOfBits];
  sum = M - sum;
  //deb(sum);
  //deb(NumberOfBits);

  for(int i=N;i>=1;i--)
    {
      ll cost = sum - C[i-1][NumberOfBits];
      if(cost >  0)
	{
	  ans += "1";
	  sum -= C[i-1][NumberOfBits];
	  NumberOfBits--;
	}
      else
	{
	  ans += "0";
	}
      //cout << "cur : " << i << " " << ans << " sum = " << sum << " NumberOfBits = " << NumberOfBits << endl;
    }

  cout << ans << endl;
}

int main()
{
  makeC();

   while(cin >> N >> M,N|M)compute();

  return 0;
}