#include <aspell.h>

#include <iostream>
#include <string>
#include <vector>

int main(int _argc, char **_argv)
{
  std::string theString;
  std::cin >> theString;

  AspellConfig *asConfig = new_aspell_config();
  aspell_config_replace(asConfig, "lang", "de_DE");

  AspellCanHaveError *possible_err = new_aspell_speller(asConfig);
  AspellSpeller *spell_checker = 0;
  if(aspell_error_number(possible_err) != 0) {
    std::cerr << aspell_error_message(possible_err) << std::endl;
  } else {
    spell_checker = to_aspell_speller(possible_err);
  }
  

  //  std::greater<char> grSorter;
  std::sort(theString.begin(), theString.end()/*, grSorter*/);

  while(std::next_permutation(theString.begin(), theString.end())) {
    int correct = aspell_speller_check(spell_checker, theString.c_str(),
				       theString.size());
    if(correct) {
      std::cout << theString << std::endl;
    }
  }

  delete_aspell_config(asConfig);
  delete_aspell_speller(spell_checker);

  return 0;
}

