#include<bits/stdc++.h>
using namespace std;
int n,l,a[10],ans,cnt;
string s;
int al[10],tal[10];
void d(int x,int sum,int nsum){
  if(x==l){
    sum+=nsum;
    if(ans==sum)cnt++;
    if(sum>ans&&sum<=n){
      ans=sum,cnt=1;
      for(int i=0;i<l;i++)tal[i]=al[i];
    }
    return;
  }
  if(sum>n)return;
  d(x+1,sum+nsum,a[x]);
  al[x]=1;
  d(x+1,sum,nsum*10+a[x]);
  al[x]=0;
}

int main(){
  while(cin>>n>>s){
    if(!n)break;
    int tn=n,sum=0;
    l=ans=0;
    cnt=1;
    for(int i=0;i<s.size();i++){
      al[i]=tal[i]=0;
      a[i]=s[i]-'0';
      sum+=a[i];
    }
    l=s.size();
    if(n<sum)cout<<"error"<<endl;
    else{
      d(1,0,a[0]);
      if(cnt==1){
	cout<<ans;
	for(int i=0;i<s.size();i++){
	  if(!tal[i])cout<<" ";
	  cout<<s[i];
	}
	cout<<endl;
      }
      else cout<<"rejected"<<endl;
    }
  }
  return 0;
}

