问题 D: Change Matrix

内存限制:256 MB 时间限制:1 S
题面:Markdown 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

There is an $n×n$ matrix where the element at the $i$\-th row and $j$\-th column is $\gcd(i,j)(1\le i,j\le n)$. There are $q$ operations, each time multiplying all the numbers in a row or a column by a number, and outputting the sum of all numbers in the current matrix, modulo $10^9+7$, ensuring that the operations are random.

输入格式

The first line contains two positive integers $n$ and $q$ . The following $q$ lines, each line is one of the following two operations respectively representing that all numbers in the $x$\-th row or column need to be multiplied by $y$: \- R x y \- C x y

输出格式

In the following $q$ lines, each line contains a single positive integer representing the answer.

输入样例 复制

4 4
R 1 172460657
R 2 774542822
R 4 337889957
C 4 863617996

输出样例 复制

689842648
337099539
40219166
875100371

数据范围与提示

$n,q \le 10^5,1 \le x \le n,0 \le y<10^9+7$ It is guaranteed that all operations are chosen independently and randomly from all valid operations with equal probability and there are at most $10$ test cases.