#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

string s; //yツづ個閉カツ篠堋療アツ表ツ記
int x,y,len;
int ans[6],ansSize,ansSum,ansFlg;
int tmp[6],size;

void solve(int rem,int idx,int sum){
	if(rem == 0 && idx == len){
		if(ansSum < sum && sum <= x){
			for(int i=0;i<size;i++) ans[i] = tmp[i];
			ansSize = size;
			ansSum = sum;
			ansFlg = 2;
		}
		else if(ansSum == sum) ansFlg = 1;
		return;
	}
	if(rem <= 0 || idx >= len) return;

	for(int nidx=idx+1;nidx<=len;nidx++){
		string sub = s.substr(idx,nidx-idx);
		int plus = atoi(&sub[0]);
		if(sum + plus <= x){
			tmp[size-rem] = plus;
			solve(rem-1,nidx,sum+plus);
		}
	}
}

string itos(int x){stringstream ss; ss<<x; return ss.str();}

int main(void){
	while(cin>>x>>y,x||y){
		s = itos(y);
		len = s.length();
		ansFlg = size = 0;
		ansSum = -1;

		//ツ閉ェツ環青板づ個個按津ィ
		for(size=1;size<=len;size++){
			solve(size,0,0);
		}

		if(ansFlg == 0)
			cout<<"error\n";
		else if(ansFlg == 1)
			cout<<"rejected\n";
		else{
			cout<<ansSum;
			for(int i=0;i<ansSize;i++) cout<<" "<<ans[i];
			cout<<endl;
		}
	}

	return 0;
}