#include "bits/stdc++.h"
#define ll long long
#define INF (1<<30)
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1237
ll t;
string num;
ll ans;
vector<ll> ans_arr;

void dfs(ll n, ll sum,vector<ll> p) {
	if (n == num.length()) {
		p.push_back(sum);
		ll Sum = 0;
		for (int i = 0; i < p.size();i++) {
			//cout << p[i] << " ";
			Sum += p[i];
		}
		//cout << endl;
		if (Sum > t) return;

		//cout << Sum << endl;

		if (Sum > ans) {
			ans = Sum;
			ans_arr = p;
		}
		else if (Sum == ans) {
			ans_arr.clear();
			ans_arr.push_back(INF);
		}
		return;
	}

	int x = num[n] - '0';

	auto temp = p;
	if(n != 0)temp.push_back(sum);
	dfs(n + 1, x, temp);
	if(n != 0)dfs(n + 1, sum * 10 + x, p);
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> t >> num) {
		if (t == 0 && num == "0")break;
		ans = -1;
		ans_arr.clear();
		vector<ll> p;
		dfs(0,0, p);

		if (ans == -1) {
			cout << "error" << endl;
			continue;
		}

		if (ans_arr[0] == INF) {
			cout << "rejected" << endl;
			continue;
		}

		cout << ans;
		for (int i = 0; i < ans_arr.size();i++) {
			cout << " " << ans_arr[i];
		}
		cout << endl;
	}
}