#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int NUM = 62;
ll combi[NUM][NUM];
void calcCombi() {
  combi[0][0] = 1;
  REP(i, NUM-1) {
    combi[i][0] = combi[i][i] = 1;
    REP(j, i)
      combi[i+1][j+1] = combi[i][j] + combi[i][j+1];
  }
}

int main() {
  calcCombi();
  // REP(i,NUM) {
  //   REP(j,NUM) cout << combi[i][j] << " ";
  //   cout << endl;
  // }
  ll n, m;
  while(cin>>n>>m,n||m) {
    ll now = m;
    ll num = 0;
    while(now - combi[n][num] > 0) {
      now -= combi[n][num];
      //cout << now << endl;
      num++;
    }
    //cout << num << endl;
    string ans(n,'0');
    for (int i=0; i<n; ++i) {
      if (num == 0) break;
      //cout << now << " " << num << " " << combi[n-i-1][num] << endl;
      if (now - combi[n-i-1][num] > 0) {
        ans[i] = '1';
        now -= combi[n-i-1][num];
        num--;
      }
    }
    cout << ans << endl;
  }
}