BaXianGuoHai, GeXianShenTong
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Let P = 998244353, for two vectors (a_0, a_1, a_2), (b_0, b_1, b_2) of length 3, Bobo defines their (multiplicative) product as

Given n 3-vectors and integers , he would like to compute q products, which are

The vectors and integers are generated given parameters m, z_0, a, b by the following codes:

z = z0
for i in 1..n
  for j in 0..2
    z = (z * a + b) mod 2^32
    v[i][j] = z mod P
for k in 1..q
  for i in 1..n
    e[k][i] = 0
    for j in 0..(m - 1)
      z = (z * a + b) mod 2^32
      e[k][i] += z * 2^{32 * j}

输入描述:

The input file contains 6 integers n, m, q, z_0, a, b.

*
*
*
*

输出描述:

Print q 3-vectors which denote the result.
示例1

输入

复制
2 2 2 0 1 1

输出

复制
213483525 14344689 213483525
664318592 664318592 318688993

备注:

For the sample, 
* ,
* ,
* , ,
* , .