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

#CC0000052. Đếm số hoa đang nở (Number of Flowers in Full Bloom)

HỌC THEO LỘ TRÌNH

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

3 lộ trình

Đếm số hoa đang nở (Number of Flowers in Full Bloom)

Number of Flowers in Full Bloom

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Flower ii blooms at every time from sis_i to eie_i, inclusive. There are qq people, with visit times tjt_j. For each person, count how many flowers are blooming at that moment, including either endpoint.

Input

The first line contains n,qn,q. The next nn lines give si,eis_i,e_i. The final line contains qq visit times tjt_j.

Output

Print qq integers, the number of flowers in bloom at each visit.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤201\le n,q\le 20; 1≤si≤ei≤1091\le s_i\le e_i\le 10^9; 1≤tj≤1091\le t_j\le10^9.
  • Subtask 2 (30 points): 1≤n,q≤15001\le n,q\le 1500; 1≤si≤ei≤1091\le s_i\le e_i\le 10^9; 1≤tj≤1091\le t_j\le10^9.
  • Subtask 3 (50 points): 1≤n,q≤500001\le n,q\le 50000; 1≤si≤ei≤1091\le s_i\le e_i\le 10^9; 1≤tj≤1091\le t_j\le10^9.

Examples

Input

4 4
1 6
3 7
9 12
4 13
2 3 7 11

Output

1 2 2 2

Explanation

At times 2, 3, 7 and 11, the bloom counts are 1, 2, 2 and 2, respectively.