#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;

int conv_stoi(string s) {
    int res = 0, pow_ten = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        res += int(s[i] - '0') * pow_ten;
        pow_ten *= 10;
    }
    return res;
}

void solve(int t, int num) {
    string number;
    int tmp = num;
    int n = 0;
    while (tmp > 0) {
        n++;
        tmp /= 10;
    }
    for (int i = 0; i < n; i++) {
        number += char(num % 10 + '0');
        num /= 10;
    }
    reverse(number.begin(), number.end());
    map<int, int> cnt, number_mask;
    int ans = -1;
    for (int mask = 0; mask < (1 << n); mask++) {
        if (!(mask & 1)) continue;
        vector<int> sep;
        for (int i = 0; i < number.size(); i++) {
            if ((mask >> i) & 1) sep.push_back(i);
        }
        int m = sep.size();
        sep.push_back(number.size());
        int sum = 0;
        vector<int> numbers;
        for (int i = 0; i < m; i++) {
            int now_number = conv_stoi(number.substr(sep[i], sep[i + 1] - sep[i]));
            numbers.push_back(now_number);
            sum += now_number;
        }
        if (sum > t) continue;
        cnt[sum]++;
        ans = max(ans, sum);
        number_mask[sum] = mask;
    }
    if (ans < 0) cout << "error" << endl;
    else if (cnt[ans] > 1) cout << "rejected" << endl;
    else {
        cout << ans << ' ';
        int ans_mask = number_mask[ans];
        vector<int> ans_sep;
        for (int i = 0; i < n; i++) {
            if ((ans_mask >> i) & 1) ans_sep.push_back(i);
        }
        int m = ans_sep.size();
        ans_sep.push_back(n);
        for (int i = 0; i < m; i++) {
            cout << conv_stoi(number.substr(ans_sep[i], ans_sep[i + 1] - ans_sep[i])) << " \n"[i == m - 1];
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t, num;
    while (true) {
        cin >> t >> num;
        if (t == 0 && num == 0) break;
        solve(t, num);
    }
    return 0;
}
