4707: P8618 [蓝桥杯 2014 国 B] Log 大侠

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Input

Output

Sample Input Copy

3 3
5 6 4
1 2
2 3
1 3

Sample Output Copy

10
8
6

HINT