编程介的小学生 2017-03-28 15:11 采纳率: 20.5%
浏览 1115
已采纳

Derivative

Calculating the derivative of a polynomial is an easy task. But what about calculating the derivative of , where is vector? Here we denote . To calculate the derivative of , you should know 5 rules:

, where is a vector here.
, where and means to take as constants for .

, where is a constant.
, where and is a constant.
Now your task is to calculate the first-derivative of for some given .

Input

The first line of the input contains an integer T (T <= 10), indicating the number of cases.

Each test case contains two blocks.
The first line of the first block contains two integers, n and m (0 < n, m <= 100), indicating the number of terms of the polynomial and the dimension of . The next n lines contain m + 1 integers each, Ci, pi1, ..., pim, indicating the coefficient and the exponent of xj of the i-th term.
The first line of the second block contains one integer Q (0 < Q <= 100), indicating the number of queries for the given f(x). Each of the following Q lines contains m integers each, indicating the entry values of .
Note: All the values in the input are nonnegative integers not exceeding 100.

Output

For each query of each test case, output the resulting first-derivative vector in one line, with entries separated by one space and no extra space at the end of the line. For the result may be very big, you are only asked to output each element mod 1000000007.

Add a blank line between two consecutive test cases. There must be no extra blank line at the end of output.

Sample Input

2
3 2
1 2 0
3 0 2
7 0 0
2
1 4
2 3
2 2
1 1 1
9 1 0
2
1 4
2 3
Sample Output

2 24
4 18

13 1
12 2

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-04-06 15:50
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法