Major legislation is often accompanied by heavy lobbying, and lobbying can involve financial contributions to lawmakers. One proposed way to handle this is to let lawmakers accept donations from any source, but then use those donations to adjust the weight of their votes: if a lawmaker received strong financial support from an industry, a vote favoring that industry is downweighted accordingly. Here we compute the outcome of such weighted votes.
There is a single vote with two options: keep the status quo (which the health industry prefers), or adopt a new health care system. For each lawmaker you are given every financial contribution from the health industry, together with the day it was made. Only contributions made within the 1000 days before the vote count. If the vote is held on day $T$, a contribution made on day $t$ is relevant only when $0 \le T - t < 1000$.
Let $D$ be the total amount of relevant donations (in dollars) received by a lawmaker.
Compute the total weighted number of votes for and against the new health care system.
The first line contains the number $K$ of data sets. It is followed by $K$ data sets, each of the following form.
The first line of a data set contains three integers $n$, $m$, $T$: $n$ is the number of lawmakers ($1 \le n \le 1000$), $m$ is the number of donations ($0 \le m \le 100000$), and $T$ is the day of the vote.
Then follow $m$ lines, each describing one donation with two integers $i$, $t$ and a floating-point number $d$: $1 \le i \le n$ is the lawmaker who received the donation, $t$ is the day it was made, and $d$ is the amount. A donation is relevant only when $0 \le T - t < 1000$.
Then follow $n$ lines; the $i$-th of them contains a single character describing lawmaker $i$'s vote. Y means the lawmaker voted for the reform (the new system), and N means the lawmaker voted against it.
For each data set, print Data Set x: on a line by itself, where $x$ is the data set number (starting from 1). On the next line, print the total weighted number of votes for the new system and the total weighted number of votes against it, separated by a single space and each rounded to two decimal places. Separate consecutive data sets with one blank line.