Ayu loves distinct letter sequences ,a distinct letter sequence is defined by a sequence of small case english alphabets such that no character appears more then once.
But however there are two phrases that she doesn't like these phrases are "kar" and "shi" and she is given a sequence of distinct characters and she wonders how many such sequences she can form using all the characters such that these phrases don't occur.
Help her finding the number of such sequences.
New Year Gift - It is guaranteed that for sequences of length greater then 6 letters k,a,r,s,h,i will be present(we thought of being generous, thank us later :)).

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each line consists of a string $S$ (3<=s.length<=18) of distinct characters.

-----Output:-----
Print the number of sequences that can be formed by permuting all the characters such that phrases "kar" and "shi" don't occur.

-----Constraints-----
- $1 \leq T \leq 10$
- $3 \leq S.length \leq 18$

-----Sample Input:-----
2
karp
abcd

-----Sample Output:-----
22
24

Starter code:

Solutions:
# cook your dish here
from collections import deque, defaultdict
from math import sqrt, ceil,factorial
import sys
import copy
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

for _ in range(int(input())):

    s=input()
    if len(s)>6:
        ans=0
        rem=len(s)-6
        ans+=factorial(len(s))
        ans-=2*(factorial(len(s)-2))
        ans+=factorial(rem+2)
        print(ans)

    else:
        if 'k' in s and 'r' in s and 'a' in s and 's' in s and 'h' in s and 'i' in s:
            ans = 0
            rem = len(s) - 6
            ans += factorial(len(s))
            ans -= 2 * (factorial(len(s) - 2))
            ans += factorial(rem + 2)
            print(ans)
        else:
            if 'k' in s and 'a' in s and 'r' in s:
                ans=0
                rem=len(s)-3
                ans+=factorial(len(s))
                ans-=factorial(rem+1)
                print(ans)
                continue
            if 's' in s and 'h' in s and 'i' in s:
                ans = 0
                rem = len(s) - 3
                ans += factorial(len(s))
                ans -= factorial(rem + 1)
                print(ans)
                continue

            print(factorial(len(s)))