#include<iostream>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;

int n,maxn;
vector<int> V,maxV;

void Shred(int sum,int m,string s)
{
  if(sum>n){
    return;
  }
  if(s.empty()){
    if(maxn==sum){
      maxV[0]=-1;
    }
    else if(maxn<sum){
      maxn=sum;
      maxV.clear();
      for(int i=0;i<V.size();i++){
	maxV.push_back(V[i]);
      }
    }
    return;
  }
  for(int i=1;i<s.length()+1;i++){
    m=atoi(s.substr(0,i).c_str());
    V.push_back(m); 
    Shred(sum+m,m,s.substr(i,s.length()));
    V.pop_back();
  }
}

int main()
{
  string s;
  int m,flag;
  while(1){
    cin>>n>>s;
    if(n==0 && s[0]=='0')break;
    maxn=0;flag=0;
    for(int i=1;i<s.length()+1;i++){
      V.clear();
      m=atoi(s.substr(0,i).c_str());
      V.push_back(m); 
      Shred(m,m,s.substr(i,s.length()));
      V.clear();
    }
    if(maxV[0]==-1)cout<<"rejected"<<endl;
    else if(maxn==0)cout<<"error"<<endl;
    else{
      cout<<maxn;
      for(int i=0;i<maxV.size();i++)cout<<" "<<maxV[i];
      cout<<endl;
    }
  }
  return 0;
}