Taxis

No attempts yetTime limit1sMemory limit128 MB

Problem

In a country with NN towns and KK roads, taxi company ii charges CiC_i and may traverse at most RiR_i consecutive roads per ride, boarding only at town ii. Find the minimum total fare from town 1 to town NN.

Input

Line 1: NN, KK. Next NN lines: CiC_i, RiR_i. Next KK lines: roads.

Output

Print the minimum total fare.