#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int t; string s; cin >> t >> s;
    if(t == 0 && s == "0") break;
    int n = s.length();
    bool reject = false;
    int sum = -INF;
    vector<int> res;
    for(int i=0;i<(1<<(n-1));i++) {
      int stmp = 0, tmp = 0;
      bool update = false;
      vector<int> v;
      for(int j=0;j<n;j++) {
        update = true;
        tmp *= 10;
        tmp += (s[j] - '0');
        if((i>>j) & 1) {
          stmp += tmp;
          v.push_back(tmp);
          tmp = 0;
          update = false;
        }
      }
      if(update) {
        stmp += tmp;
        v.push_back(tmp);
      }
      if(stmp < sum || t < stmp) {
        continue;
      }
      if(stmp == sum) {
        reject = true;
      } else {
        reject = false;
        res = v;
        sum = stmp;
      }
    }
    if(sum == -INF) {
      cout << "error" << endl;
    } else if(reject) {
      cout << "rejected" << endl;
    } else {
      cout << sum;
      for(int i=0;i<(int)res.size();i++) {
        cout << " " << res[i];
      }
      cout << endl;
    }
  }
}

