#include "/Users/fatihmerickoc/stdc++.h"
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
bool isFactorial(long long n)
{
for (int i = 1;; i++) {
if (n % i == 0) {
n /= i;
}
else {
break;
}
}
if (n == 1) {
return true;
}
else {
return false;
}
}
void doReverseFactorial(long long num)
{
long long reverse = num;
bool ans = isFactorial(reverse);
if (ans == 1)
{
for (int a = 2; reverse != a; a++)
{
reverse = reverse / a;
}
cout << to_string(reverse) << endl;
}
}
void display(long long vector[], int vectorSize)
{
long long num = 0;
for (int i = 0; i < vectorSize; i++) {
num *= 10;
num += vector[i];
}
doReverseFactorial(num);
}
// Function to find the permutations
void findPermutations(long long vector[], int vectorSize)
{
// Sort the given array
// Find all possible permutations
do {
display(vector, vectorSize);
} while (next_permutation(vector, vector + vectorSize));
}
int main(){
int numberDigits[10];
vector<long long> realNumbers;
//read all 10 digits
for (int i = 0; i < 10; i++)
{
cin >> numberDigits[i];
}
//add elements to vector
for (int f = 0; f < 10; f++)
{
if (numberDigits[f] != 0)
{
int times = numberDigits[f];
for (int x = 0; x < times; x++)
{
realNumbers.push_back(f);
}
}
}
int vectorSize = realNumbers.size();
long long arr[vectorSize];
for (int i = 0; i < vectorSize; i++) {
arr[i] = realNumbers[i];
}
findPermutations(arr, vectorSize);
return 0;
}