#include <iostream>
using namespace std;
int stack[100], n;
void subsets(int level) {
if( level <= n ) {
for(int i = stack[level-1]+1; i <= n; ++i) {
stack[level] = i;
for(int j = 1; j <= level;++j)
cout<<stack[j]<<" ";
cout<<endl;
subsets(level+1);
}
}
}
int main() {
n = 3;
subsets(1);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBzdGFja1sxMDBdLCBuOwoKdm9pZCBzdWJzZXRzKGludCBsZXZlbCkgewogICAgIGlmKCBsZXZlbCA8PSBuICkgewogICAgICAgICBmb3IoaW50IGkgPSBzdGFja1tsZXZlbC0xXSsxOyBpIDw9IG47ICsraSkgewogICAgICAgICAgICAgc3RhY2tbbGV2ZWxdID0gaTsKICAgICAgICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gbGV2ZWw7KytqKQogICAgICAgICAgICAgY291dDw8c3RhY2tbal08PCIgIjsKICAgICAgICAgICAgIGNvdXQ8PGVuZGw7CiAgICAgICAgICAgICBzdWJzZXRzKGxldmVsKzEpOwogICAgICAgICB9CiAgICAgfQp9CgppbnQgbWFpbigpIHsKCW4gPSAzOwoJc3Vic2V0cygxKTsKfQ==