#include <iostream>
using namespace std;
void permSum(string s, string perm)
{
cout << perm << endl;
if(s.empty()) return;
for(int i=0; i<s.length(); i++)
permSum(s.substr(0,i)+s.substr(i+1, string::npos), perm+s[i]);
}
int main() {
permSum("abc", "");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBwZXJtU3VtKHN0cmluZyBzLCBzdHJpbmcgcGVybSkKewoJY291dCA8PCBwZXJtIDw8IGVuZGw7CglpZihzLmVtcHR5KCkpIHJldHVybjsKCWZvcihpbnQgaT0wOyBpPHMubGVuZ3RoKCk7IGkrKykKCSAgcGVybVN1bShzLnN1YnN0cigwLGkpK3Muc3Vic3RyKGkrMSwgc3RyaW5nOjpucG9zKSwgcGVybStzW2ldKTsKfQoKaW50IG1haW4oKSB7CglwZXJtU3VtKCJhYmMiLCAiIik7CglyZXR1cm4gMDsKfQ==