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.

d_Coder00 | 134 |

Astikeysingh | 128 |

dungeon_master1299 | 126 |

rajendrashekhawat063 | 115 |

VivSisMMM | 112 |

Pulkit__Sharma__ | 646 |

Anirban166 | 531 |

abducodes | 508 |

Found_me | 474 |

Sathvik Avasarala | 418 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.