Given a string of lowercase alphabets, count all possible substrings (not necessarily distinct) that have exactly k distinct characters.
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of two lines. The first line of each test case consists of a string S.
The second line of each test case contains integer K.
Corresponding to each test case, in a new line, print the count all possible substrings that has exactly k distinct characters.
1 ≤ T ≤ 100
1 ≤ string length ≤ 1000
1 ≤ K ≤ 26
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.