#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string s("ABC");
do {
cout << s << endl;
} while (next_permutation(s.begin(), s.end()));
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CgpzdHJpbmcgcygiQUJDIik7CmRvIHsKICAgIGNvdXQgPDwgcyA8PCBlbmRsOwp9IHdoaWxlIChuZXh0X3Blcm11dGF0aW9uKHMuYmVnaW4oKSwgcy5lbmQoKSkpOwoKCXJldHVybiAwOwp9