#include <bits/stdc++.h>
using namespace std;

bool contains123(int num) {
    bool has1 = false, has2 = false, has3 = false;

    while (num > 0) {
        int digit = num % 10;

        if (digit == 1) has1 = true;
        else if (digit == 2) has2 = true;
        else if (digit == 3) has3 = true;

        num /= 10;
    }

    return has1 && has2 && has3;
}

int main() {
    vector<int> arr;
    int x;

    // Read input numbers until EOF
    while (cin >> x) {
        arr.push_back(x);
    }

    vector<int> ans;

    for (int num : arr) {
        if (contains123(num)) {
            ans.push_back(num);
        }
    }

    if (ans.empty()) {
        cout << -1;
    } else {
        sort(ans.begin(), ans.end());

        for (int i = 0; i < ans.size(); i++) {
            if (i > 0) cout << ",";
            cout << ans[i];
        }
    }

    return 0;
}