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

int main()
{
	string A, B, C;
	string resenje1, resenje2, resenje3, resenje4, resenje5, resenje6, resenje;
	cin >> A >> B >> C;
	resenje1 = A + B + C;
	resenje2 = A + C + B;
	resenje3 = B + A + C;
	resenje4 = B + C + A;
	resenje5 = C + A + B;
	resenje6 = C + B + A;
	
	resenje = max (max (max( max (max (resenje1, resenje2), resenje3), resenje4), resenje5), resenje6);
	cout << resenje;


	cout << resenje1 << ' ' << resenje2 << ' ' << resenje3 << ' ' << resenje4 << ' ' << resenje5 << ' ' << resenje6;

    return 0;
}