#1491. 志愿者招募加强版

志愿者招募加强版

Description

image

Format

Input

image

Output

image

Samples

3 3
2 3 4
1 1 2 2
1 2 3 5
1 3 3 2
14

Limitation

image