DSUBSEQ  Distinct Subsequences
Given a string, count the number of distinct subsequences of it ( including empty subsequence ). For the uninformed, A subsequence of a string is a new string which is formed from the original string by deleting some of the characters without disturbing the relative positions of the remaining characters.
For example, "AGH" is a subsequence of "ABCDEFGH" while "AHG" is not.
Input
First line of input contains an integer T which is equal to the number of test cases. You are required to process all test cases. Each of next T lines contains a string s.
Output
Output consists of T lines. Ith line in the output corresponds to the number of distinct subsequences of ith input string. Since, this number could be very large, you need to output ans%1000000007 where ans is the number of distinct subsequences.
Example
Input: 3 AAA ABCDEFG CODECRAFT Output: 4 128 496
Constraints and Limits
T ≤ 100, length(S) ≤ 100000
All input strings shall contain only uppercase letters.
hide comments
javafreak:
20171028 23:37:16
Yes, it is important to add 'mod' wherever the answer can be negative. GeeksforGeeks tutorial might be helpful. 

raghav_chawla7:
20170925 09:27:12
take care of mod.Cost me 1WA 

babur:
20170629 09:01:15
One of the finest problem....loved to solve it :) 

sandeep_4141:
20170616 14:12:19
take care about MOD !!


kabramanan:
20170531 16:30:49
Just add mod wherever you think the answer could be negative.


kush_code:
20170517 18:20:38
input contains lowercase characters also.


sfialok98:
20170403 21:33:39
Very nice Problem.....


nilabja16180:
20170324 15:50:27
GOOD problem! 

vunnamtej:
20170309 14:51:24
good dp. string to maths 

ipg_2015054:
20170221 19:27:27
@Avik Sarkar how can the value be negative..please explain 
Added by:  Ajay Somani 
Date:  20080205 
Time limit:  0.245s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: CPP 
Resource:  CodeCraft 08, Problem Setter: Jin Bin 