Given a string **s**. Let **k** be the maximum number of partitions possible of the given string with each partition starts with a distinct letter. The task is to find the number of ways string **s **can be split into **k** partition (non-empty) such that each partition starts with a distinct letter. Print number modulo 1000000007

**Input:**

The first line contains an integer **T, **the number of test cases. For each test case, there is a string **s. **

**Output:**

For each test case, the output is the maximum number of ways modulo 1000000007.

**Constraints:**

1<=T<=100

1<=s.length()<=10^3

'A'<=s[i]<='z'

**Note: **String is not case sensitive.

**Example:
Input**

2

abB

abbcc

2

4

**Explanation
1. ** "abB" can be maximum split into 2 partitions {a, bB} with distinct starting letter, so k = 2. And, the number of ways to split "abb" into 2 partitions with distinct starting letter is 2 that are {a, bB} and {ab, B}.

Author: Vanshika_pec

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.

VISHESHA SADU | 27 |

ghanshyam648 | 25 |

Biswajit3 | 21 |

karthik_kasaragadda | 20 |

tanya_sharma | 18 |

KshatriyaYash | 1066 |

nikhil_sojan | 978 |

lonecoder | 935 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4468 |

Quandray | 4444 |

Login to report an issue on this page.