#P10945. [2015杭电多校]Yet Another XYZ Problem
[2015杭电多校]Yet Another XYZ Problem
Yet Another XYZ Problem
Problem Description
You have two strings and which consist of . Every time, you can do one of the following three operations:
- Change all the in A into . This operation costs .
- Change all the in A into . This operation costs .
- Change all the in A into . This operation costs . One extra restriction is that when you operate any of these operations, the string needs to be changed. More specifically, when you operate the first operation, there should be at least one in string , etc. Please calculate how many different ways there are to change the string into string , while using not more than total cost. The answer could be very large, so please print the actual answer module .
Input
The first line of the input is a single integer , indicating the number of testcases. For each of the testcases, the first line contains four integers $Cost0, Cost1, Cost2, maxCost(1 \le Cost0, Cost1, Cost2 \le 1e18, 0 \le maxCost \le 1e18)$. The second line contains the string , and the third line contains the string . It is guaranteed that the length of is the same with that of . The size of the input file is less than KB.
Output
For each testcase, print one integer indicating the answer.
Sample Input
3
1 1 1 0
x
x
1 1 1 0
x
y
1 1 1 10
x
x
Sample Output
1
0
4
Author
XJZX
Source
2015 Multi-University Training Contest 4