F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Senior's String

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 818    Accepted Submission(s): 364


Problem Description
Xuejiejie loves strings most. In order to win the favor of her, a young man has two strings $X$, $Y$ to Xuejiejie. Xuejiejie has never seen such beautiful strings! These days, she is very happy. But Xuejiejie is missish so much, in order to cover up her happiness, she asks the young man a question. In face of Xuejiejie, the young man is flustered. So he asks you for help.

The question is that :
Define the $L$ as the length of the longest common subsequence of $X$ and $Y$.( The subsequence does not need to be continuous
in the string, and a string of length $L$ has $2^L$ subsequences containing the empty string ). Now Xuejiejie comes up with all subsequences of length $L$ of string $X$, she wants to know the number of subsequences which is also the subsequence of string $Y$.
 

Input
In the first line there is an integer $T$, indicates the number of test cases.

In each case:

The first line contains string $X$, a non-empty string consists of lowercase English letters.

The second line contains string $Y$, a non-empty string consists of lowercase English letters.

$1\leq |X|,|Y|\leq 1000$, $|X|$ means the length of $X$.
 

Output
For each test case, output one integer which means the number of subsequences of length $L$ of $X$ which also is the subsequence of string $Y$ modulo $10^9 + 7$.
 

Sample Input
2 a b aa ab
 

Sample Output
1 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 00:40:11, Gzip enabled