Determine The combination

Jahir is a student of NSU (Nice Students’ University). He hates the chapter Permutation & Combination of the subject Discrete Math. But his teacher give him a assignment to generate all the r combination of a string. But he is too busy with his new girlfriend to do the assignment himself. So he went to Shabuj, a student of CSE (Calculation Science and Engineering) in BUET (Bangladesh University of Extraordinary Talents). He asked him to make a program to generate the combinations. But Shabuj is always lazy. He wants your help. Your task is to print all different r combinations of a string s (a r combination of a string s is a collection of exactly r letters from different positions in s). There may be different permutations of the same combination; consider only the one that has its r characters in non-decreasing order. The string consists of only lowercase letters. Any letter can occur more than once. Input The input is consist of several test cases. Each test case consists of a string s (the length of s is between 1and30)andanintegerr(0<r≤lengthof s). Output For each test case you have to print all different r combinations of s in lexicographic order in separate line. You can assume there are at most 1000 different ones. Sample Input abcde 2 abcd 3 aba 2 Sample Output ab ac ad ae bc bd be cd ce de abc abd acd bcd aa ab