The Cybersoft Computer Company (a leader in programming languages) has hired you to work on a new programming language named A--. Your job is the array-mapping part of the language: given an array reference such as x[5, 6], you must map it to an actual physical address. To do this, write a program that reads several array declarations and references and prints the physical address of each reference. Every physical address must be printed as a base-10 integer.
The physical address of an array reference $A[i_1, i_2, \ldots, i_D]$ is given by
$$C_0 + C_1 i_1 + C_2 i_2 + \cdots + C_D i_D,$$
where the constants $C_0, \ldots, C_D$ are defined as follows:
The first line contains two positive integers $N$ and $R$: $N$ is the number of arrays that are declared, and $R$ is the number of array references whose addresses must be computed. The next $N$ lines each declare one array, and the following $R$ lines each contain one array reference.
Each array-declaration line contains, in order: the array name (at most 10 characters), a positive integer giving the base address of the array, a positive integer giving the size in bytes of each array element, and $D$, the number of dimensions ($1 \le D \le 10$). These are followed, on the same line, by $D$ pairs of integers giving the lower and upper bounds of dimensions $1, \ldots, D$, respectively.
Each array-reference line contains the array name followed by the integer indices $i_1, i_2, \ldots, i_D$, where $D$ is the number of dimensions of that array.
For each reference, print one line containing the reference together with its physical address, formatted exactly as follows:
[.] = ).