#include <iostream>
#include <string>
#include <algorithm>
using std::cout;
using std::endl;
using std::string;
int main()
{
string s = "abc";
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end()));
cout << endl;
return 0;
}
/*
run:
abc
acb
bac
bca
cab
cba
*/