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

#PS0000268. Cập nhật cấp số cộng một đoạn (Increasing Range Updates)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Cập nhật cấp số cộng một đoạn (Increasing Range Updates)

Increasing Range Updates

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

An array AA of NN elements is initially zero, indexed from 1. Each operation gives l,rl,r. Add i−l+1i-l+1 to each AiA_i for l≤i≤rl\le i\le r, leaving other elements unchanged. Print the array after all QQ operations.

Input

First line: N,QN,Q. Next QQ lines: l,rl,r.

Output

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

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le 100; 1≤Q≤1001\le Q\le 100; 1≤l≤r≤N1\le l\le r\le N.
  • Subtask 2 (30 points): 1≤N≤2000001\le N\le 200000; 1≤Q≤2000001\le Q\le 200000; 1≤l≤r≤N1\le l\le r\le N; l=1l=1 for all operations.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤Q≤2000001\le Q\le 200000; 1≤l≤r≤N1\le l\le r\le N.

Example 1

Input

5 2
2 4
3 5

Output

0 1 3 5 3

Explanation

After the first operation: 0 1 2 3 0; the second adds 0 0 1 2 3.

Example 2

Input

3 2
1 3
3 3

Output

1 2 4

Explanation

Add 1 2 3, then add one more at position 3.