Under construction

Still being built. Things may change

Inspections

Time limit2sMemory limit1024 MB

Summary
Given m tasks that each run a range of n machines in order, count the inspections needed for each safety value s in a list.
Level

Hard8 of 10

Topics
Intervals, Sorting, Binary search, Implementation
Solved
No attempts yet

Problem

Benson the Rabbit now has to build a plane!

Benson the Rabbit runs a factory with nn machines numbered from 1 to nn. Each machine runs for one day, and only one machine can run at a time. Benson has mm tasks numbered from 1 to mm. Task ii is given by two positive integers lil_i and rir_i, where li≤ril_i \le r_i.

To complete task ii, Benson must run machines li,li+1,…,ril_i, l_i+1, \dots, r_i in that order. When a machine finishes, the next machine starts immediately. When task ii is complete, Benson immediately starts task i+1i+1, and so on until task mm is complete.

To follow safety regulations, the factory has a safety value ss. If a machine has not been run in the past ss or more days, it must be inspected before it can run. A machine does not need to be inspected the first time it is run.

Benson has qq candidate safety values s1,s2,…,sqs_1, s_2, \dots, s_q. For each sjs_j, compute the number of inspections needed if the safety value is sjs_j.

Input

The first line contains three space-separated integers nn, mm, and qq. The next mm lines each contain two space-separated integers lil_i and rir_i, describing task ii. The last line contains qq space-separated integers s1,s2,…,sqs_1, s_2, \dots, s_q.

Output

Output one line with qq space-separated integers. The jj-th integer is the number of inspections needed when the safety value is sjs_j.

Constraints

  • 1≤n,m,q≤2000001 \le n, m, q \le 200000
  • 1≤li≤ri≤n1 \le l_i \le r_i \le n
  • 0≤sj≤10120 \le s_j \le 10^{12}

Examples2

  1. Example 1

    Input
    5 3 7
    1 3
    3 5
    2 3
    0 1 2 3 4 5 6
    
    Expected output
    3 2 2 2 1 0 0
    
  2. Example 2

    Input
    6 6 7
    1 6
    1 5
    1 4
    1 3
    1 2
    1 1
    1 2 3 4 5 6 7
    
    Expected output
    15 14 12 9 5 0 0