#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	ll n;
	while (cin >> n, n) {
		int cnt = 0;
		bitset<52> b = 0;
		string s; cin >> s;
		rep(i,52)if (s[i] == '1')b[51-i] = 1;
		bitset<52> x = 0;
		x = b;
		cnt++; n--;
		while (n > 0) {
			if (cnt > 52)break;
			//cout << cnt << " " << n << " " << x << endl;
			bitset<52> c = b; c >>= cnt; 
			if (cnt)c[52-cnt] = 1;
			if (c == 0)break;
			ll le = 0, ri = INF;
			while (ri - le > 1) {
				ll mid = (ri + le) / 2;
				ll s = 0;
				rep(i, 52) {
					if (x[i]) {
						s++;
					}
					if (c[i]) {
						s += mid;
					}
					s /= 2;
				}
				if (s > 0)ri = mid;
				else le = mid;
			}
			if (n < ri) {
				ll s = 0;
				rep(i, 52) {
					if (x[i])s++;
					if (c[i])s += n;
					if (s % 2)x[i] = 1;
					else x[i] = 0;
					s /= 2;
				}
				break;
			}
			else {
				n -= ri;
				ll s = 0;
				rep(i, 52) {
					if (x[i])s++;
					if (c[i])s += ri;
					if (s % 2)x[i] = 1;
					else x[i] = 0;
					s /= 2;
				}
				cnt++; x >>= 1;
				if (cnt == 1)x[51] = 1;
			}
		}
		string ans;
		rep(i, 12) {
			if (cnt&(1 << (11-i))) {
				ans.push_back('1');
			}
			else ans.push_back('0');
		}
		per(i, 52) {
			if (x[i])ans.push_back('1');
			else ans.push_back('0');
		}
		cout << ans << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}
