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.

ramabhatta | 35 |

Shubham Awasthi | 34 |

pguptacse17 | 30 |

abhithakur588 | 28 |

adityasuman2025 | 27 |

the_coder95 | 1236 |

RishabhTanwar1 | 1104 |

thanuvinu94 | 676 |

tathagat289 | 664 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4889 |

Quandray | 4547 |

Login to report an issue on this page.