#493. [2009国家集训队]剪枝

[2009国家集训队]剪枝

Background

Special for beginners, ^_^

Description

image

Format

Input

image

Output

image

Samples

10
7 3 8 9 10
4 1 5
10 0
10 0
1 1 4
4 0
4 1 3
3 0
3 1 2
9 2 7 6
8

Limitation

N<=100000 Wi<=10000