#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

bool check(int a, int b, Vi v){
	int sum = 0;
	rep(i,a) sum += v[i];
	if(sum > b) return true;
	else return false;
}

int ipow(int a){
	int ret = 1;
	rep(i,a) ret *= 10;
	return ret;
}

int M(Vi v, int a){
	int ret = 0;
	rep(i,a) ret += v[i]*ipow(a-1-i);
	return ret;
}

int main(){
	int n;
	string str;
	while(cin >> n >> str){
		if(n == 0 && str[0] == '0') break;
		int p = str.size();
		Vi num(p);
		rep(i,p) num[i] = str[i]-'0';
		int sum = -1;
		Vi ans;
		if(check(p,n,num)){
			cout << "error" << endl;
			continue;
		}
		if(p == 6){
			sum = 0;
			rep(i,p){
				sum += num[i];
				ans.pb(num[i]);
			}
		}
		if(n >= M(num,p)){
			cout << M(num,p) << " " << M(num,p) << endl;
			continue;
		}
		
		for(int i = 0; i < p-1; i++){
			int x[2];
			rep(f,2) x[f] = 0;
			for(int f = 0; f <= i; f++) x[0] += num[f]*ipow(i-f);
			for(int f = i+1; f < p; f++) x[1] += num[f]*ipow(p-f-1);
			int tmp = 0;
			rep(f,2) tmp += x[f];
			if(tmp == sum) ans.clear();
			else if(tmp > sum && tmp <= n){
				ans.clear();
				sum = tmp;
				rep(f,2) ans.pb(x[f]);
			}
		}
		//cout << sum << endl;
		for(int i = 0; i < p-2; i++){
			for(int j = i+1; j < p-1; j++){
				int x[3];
				rep(f,3) x[f] = 0;
				for(int f = 0; f <= i; f++) x[0] += num[f]*ipow(i-f);
				for(int f = i+1; f <= j; f++) x[1] += num[f]*ipow(j-f);
				for(int f = j+1; f < p; f++) x[2] += num[f]*ipow(p-f-1);
				int tmp = 0;
				rep(f,3) tmp += x[f];
				if(tmp == sum) ans.clear();
				else if(tmp > sum && tmp <= n){
					ans.clear();
					sum = tmp;
					rep(f,3) ans.pb(x[f]);
				}
			}
		}
		//cout << sum << endl;
		for(int i = 0; i < p-3; i++){
			for(int j = i+1; j < p-2; j++){
				for(int k = j+1; k < p-1; k++){
					int x[4];
					rep(f,4) x[f] = 0;
					for(int f = 0; f <= i; f++) x[0] += num[f]*ipow(i-f);
					for(int f = i+1; f <= j; f++) x[1] += num[f]*ipow(j-f);
					for(int f = j+1; f <= k; f++) x[2] += num[f]*ipow(k-f);
					for(int f = k+1; f < p; f++) x[3] += num[f]*ipow(p-f-1);
					int tmp = 0;
					rep(f,4) tmp += x[f];
					if(tmp == sum) ans.clear();
					else if(tmp > sum && tmp <= n){
						ans.clear();
						sum = tmp;
						rep(f,4) ans.pb(x[f]);
					}
				}
			}
		}
		//cout << sum << endl;
		for(int i = 0; i < p-3; i++){
			for(int j = i+1; j < p-2; j++){
				for(int k = j+1; k < p-1; k++){
					for(int l = k+1; l < p-1; l++){
						int x[5];
						rep(f,5) x[f] = 0;
						for(int f = 0; f <= i; f++) x[0] += num[f]*ipow(i-f);
						for(int f = i+1; f <= j; f++) x[1] += num[f]*ipow(j-f);
						for(int f = j+1; f <= k; f++) x[2] += num[f]*ipow(k-f);
						for(int f = k+1; f <= l; f++) x[3] += num[f]*ipow(l-f);
						for(int f = l+1; f < p; f++) x[4] += num[f]*ipow(p-f-1);
						int tmp = 0;
						rep(f,5) tmp += x[f];
						if(tmp == sum) ans.clear();
						else if(tmp > sum && tmp <= n){
							ans.clear();
							sum = tmp;
							rep(f,5) ans.pb(x[f]);
						}
					}
				}
			}
		}
		//cout << sum << endl;
		if(ans.size() == 0){
			cout << "rejected" << endl;
		} else{
			cout << sum;
			rep(i,ans.size()) cout << " " << ans[i];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1228