#include<iostream>
#include<string>
using namespace std;
long long dp[65][65];
int main() {
	dp[0][0] = 1;
	for (int i = 0; i < 64; i++) {
		for (int j = 0; j < 64; j++) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j];
		}
	}
	while (true) {
		long long n, k, c = 0; string S = "";
		cin >> n >> k; if (n == 0)break;
		for (int i = 0; i <= n; i++) {
			if (c + dp[n][i] >= k) { k -= c; c = i; break; }
			c += dp[n][i];
		}
		for (int i = n; i >= 1; i--) {
			if (c == 0) { S += "0"; }
			else {
				if (k <= dp[i - 1][c]) { S += "0"; }
				else { k -= dp[i - 1][c]; S += "1"; c--; }
			}
		}
		cout << S << endl;
	}
	return 0;
}