#include<iostream>#include<cstring>#include<cstdio>using namespace std;int target;string num;int mat[10][10];int Max,flag[10],reject;int f[10];void dfs( int x,int count ){ flag[x] = 1; int i; if( x == num.length() ) { if( count == Max && count <= target ) reject ++; if( count > Max && count <= target ) { Max = count; reject = 1; memcpy(f,flag,sizeof(f)); } flag[x] = 0; return; } for( i = x; i < num.length(); i++ ) dfs( i+1, count + mat[x][i]); flag[x] = 0;}int main(void){ int i,j,k,sum; while( cin >> target >> num ) { if( !target && num == "0" ) break; Max = -1;reject = 0; for( i = 0; i < num.length(); i++ ) for( j = i; j < num.length(); j++ ) { sum = 0; for( k = i; k <= j; k++ ) sum = sum * 10 + num[k]-'0'; mat[i][j] = sum; } memset(flag,0,sizeof(flag)); dfs( 0,0 ); if( reject == 0 ) cout << "error" << endl; else if( reject > 1 ) cout << "rejected" << endl; else { cout << Max ; for( i = 0; i < num.length(); i++ ) { if( f[i] ) cout << ' '; cout << num[i]; } cout << endl; } } return 0;}