PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000252. Cộng cấp số cộng trên đoạn (Arithmetic Progression Range Addition)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cộng cấp số cộng trên đoạn (Arithmetic Progression Range Addition)

Arithmetic Progression Range Addition

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Initially AA contains NN zeros indexed from 1. Perform QQ operations (l,r,d)(l,r,d): add d,2d,…,(r−l+1)dd,2d,\ldots,(r-l+1)d to positions ll through rr respectively. Other positions stay unchanged. dd may be negative or zero. Print the final array.

Input

First line: N,QN,Q. Each of the next QQ lines contains l,r,dl,r,d.

Output

Print NN integers A1,…,ANA_1,\ldots,A_N on one line, separated by spaces.

Subtasks

  • Subtask 1 (20 points): 1≤N,Q≤1001\le N,Q\le 100; 1≤l≤r≤N1\le l\le r\le N; −106≤d≤106-10^6\le d\le10^6.
  • Subtask 2 (30 points): 1≤N,Q≤2000001\le N,Q\le 200000; 1≤l≤r≤N1\le l\le r\le N; −106≤d≤106-10^6\le d\le10^6; l=rl=r.
  • Subtask 3 (50 points): 1≤N,Q≤2000001\le N,Q\le 200000; 1≤l≤r≤N1\le l\le r\le N; −106≤d≤106-10^6\le d\le10^6.

Example 1

Input

5 2
2 4 3
1 3 -2

Output

-2 -1 0 9 0

Explanation

After operation 1: [0,3,6,9,0]. Operation 2 adds −2,−4,−6 to the first three cells.

Example 2

Input

1 2
1 1 5
1 1 -5

Output

0

Explanation

The two operations cancel.