#include<stdio.h>
#include<vector>
#include<map>
typedef std::vector<int>V;
typedef std::pair<int,V>P;
V s;
std::vector<P>v;
int t,a[]={10,100,1000,10000,100000,1000000};
void F(int n,int d,int c)
{
	if(d-1==c)
	{
		s.push_back(n);
		int m,i;
		for(m=i=0;i<s.size();++i)m+=s[i];
		if(t>=m)
		{if(v[0].first<m)v.clear(),v.push_back(P(m,s));
			else if(v[0].first==m)v.push_back(P(m,s));
		}
		s.pop_back();
	}
	else
	{
		F(n,d,c+1);
		s.push_back(n%a[c]);
		n/=a[c];
		F(n,d-c-1,0);
		s.pop_back();
	}
}
int main()
{
	int a,d,i;
	while(scanf("%d%d",&t,&a),t)
	{
		v.clear();
		v.push_back(P());
		for(i=a,d=0;i;++d)i/=10;
		F(a,d,0);
		if(v[0].first==0)puts("error");
		else if(v.size()>1)puts("rejected");
		else
		{for(printf("%d",v[0].first), i=v[0].second.size()-1;i>=0;--i)
				printf(" %d",v[0].second[i]);
			puts("");
		}
	}
	return 0;
}