#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<functional>
using namespace std;

#define MAX_N 19

long long K, m;
int dig[MAX_N], cut[MAX_N], sum;
vector<pair<long long, string>>vec;
char T[11] = "0123456789";

void _memset() {
	sum = 0;
	for (int i = 0; i < MAX_N; i++) {
		dig[i] = 0;
		cut[i] = 0;
	}
	vec.clear();
}

long long power(long long n, long long v) {
	long long res = 1;
	for (int i = 0; i < v; i++) {
		res *= n;
	}
	return res;
}

int digits(long long n) {
	for (int i = 0; i < MAX_N; i++) {
		if (power(10, i) >= n) { return i + 1; }
	}
}

long long STOI(string U) {
	long long res = 0;
	for (int i = 0; i < U.size(); i++) {
		for (int j = 0; j < 10; j++) {
			if (U[i] == T[j]) {
				res += power(10, U.size() - 1 - i)*j;
			}
		}
	}
	return res;
}

string TOSTR(long long n) {
	string S = ""; bool ok = false;
	for (int i = MAX_N - 1; i >= 0; i--) {
		long long b = power(10, i);
		long long c = (n / b) % 10;
		if (c >= 1) {
			ok = true;
		}
		if (ok == true) {
			S += T[c];
		}
	}
	return S;
}

string make(vector<long long>vect) {
	string W = "";
	for (int i = 0; i < vect.size(); i++) {
		if (i >= 1) { W += ','; }
		W += TOSTR(vect[i]);
	}
	return W;
}

vector<long long>kaiseki(string W) {
	vector<long long>vec4;
	string X = "";
	W += ',';
	for (int i = 0; i < W.size(); i++) {
		if (W[i] == ',') {
			vec4.push_back(STOI(X));
			X = "";
		}
		else {
			X += W[i];
		}
	}
	return vec4;
}

int main() {
	while (true) {
		_memset();
		cin >> K >> m;
		if (K == 0 && m == 0) {
			break;
		}

		int digit = digits(m);
		string S = "";
		vector<long long>vec2;
		vec2.clear();

		for (int i = 0; i < MAX_N; i++) {
			dig[i] = (m / power(10, i)) % 10;
		}
		for (int i = 0; i < power(2, digit - 1); i++) {
			S = "";
			sum = 0;
			vec2.clear();
			for (int j = 0; j < MAX_N; j++) {
				cut[j] = 0;
			}
			for (int j = 0; j < digit - 1; j++)
			{
				int a = power(2, j);
				cut[j] = (i / a) % 2;
			}

			for (int j = digit - 1; j >= 1; j--) {
				S += T[dig[j]];
				if (cut[j - 1] == 1) {
					vec2.push_back(STOI(S));
					sum += vec2[vec2.size() - 1];
					S = "";
				}
			}
			S += T[dig[0]];
			vec2.push_back(STOI(S));
			sum += vec2[vec2.size() - 1];
			S = "";

			if (sum <= K && vec2[0] != 0) {
				vec.push_back(make_pair(sum, make(vec2)));
			}
		}
		sort(vec.begin(), vec.end(),greater<pair<long long, string>>());

		long long target;
		int sum2 = 0;

		if (vec.size() >= 1) {
			sum2 = 0;
			target = vec[0].first;
			for (int i = 0; i < vec.size(); i++) {
				if (vec[i].first == target) {
					sum2++;
				}
				else {
					break;
				}
			}
		}
		if (sum2 == 0) {
			cout << "error" << endl;
		}
		if (sum2 >= 2) {
			cout << "rejected" << endl;
		}
		if (sum2 == 1) {
			cout << vec[0].first << ' ';
			vector<long long>vec3 = kaiseki(vec[0].second);
			for (int i = 0; i < vec3.size(); i++) {
				if (i >= 1) { cout << ' '; }
				cout << vec3[i];
			}
			cout << endl;
		}

	}
	return 0;
}