Consider the following generalization of Roman numerals. There are $n$ digits in total, and each digit has its own priority and value. In this problem, we will denote the numerals by strings of lowercase and uppercase English letters. Let us denote the priority, value, and string representation of the $i$-th Roman numeral by $p_i$, $v_i$, and $d_i$, respectively.
A number in Roman numerals is an array consisting of Roman numerals. The value of a number $d_1 \dots d_m$ is calculated recursively. First, choose a position $i$ such that the digit $d_i$ has the highest priority. In case there are multiple digits with the highest priority, choose one of them with the lowest position $i$. Then
$$\operatorname{value}(d_1 \dots d_m) = v_i - \operatorname{value}(d_1 \dots d_{i-1}) + \operatorname{value}(d_{i+1} \dots d_m),$$
where $v_i$ is the value of $d_i$. The value of an empty number is conventionally set to zero.
For example, consider the following triples $(p_i, v_i, d_i)$: $(1, 1, \texttt{I})$, $(2, 5, \texttt{V})$, and $(3, 10, \texttt{X})$. They assign the usual values to the usual Roman numerals: for example, $\operatorname{value}(\texttt{II}) = 2$, $\operatorname{value}(\texttt{IX}) = 9$, and $\operatorname{value}(\texttt{XIV}) = 14$. On the other hand, the representation now is not unique: $\operatorname{value}(\texttt{IXI}) = \operatorname{value}(\texttt{IIIIIXV}) = \operatorname{value}(\texttt{X}) = 10$.
You are given an array $s_1 \dots s_n$ of Roman numerals and $q$ independent queries of the form $(\ell, r)$. For each query, calculate the value of the subarray $s_\ell \dots s_r$.
Input
The first line contains three integers $m$, $n$, and $q$ ($1 \le m \le 10^5$, $1 \le n, q \le 3 \cdot 10^5$): the number of Roman numerals, the length of the given array, and the number of queries.
Then follow $m$ lines. The $i$-th of them contains two integers, $p_i$ and $v_i$ ($1 \le p_i \le m$, $1 \le v_i \le 10^9$), followed by a string $d_i$ of lowercase and uppercase English letters ($1 \le |d_i| \le 7$). These are the priority, value, and string representation of the $i$-th Roman numeral, respectively. All $d_i$ are distinct.
The next line contains $n$ space-separated representations of Roman numerals $s_1 \dots s_n$.
Then follow $q$ lines, each of them containing two integers $\ell$ and $r$ ($1 \le \ell \le r \le n$).
Output
For each query, output a line with a single integer: the value of the number $s_\ell \dots s_r$.
Examples
Input 1
3 5 3 1 1 I 2 5 V 3 10 X I X I V X 1 2 1 3 3 5
Output 1
9 10 6
Input 2
3 6 1 1 6 six 1 16 sixteen 1 60 sixty six sixty six sixteen six sixteen 1 6
Output 2
110