Problem Description
[Title] background
Little bit strange spacecraft opens up unlimited endurance + precise acquisition mode! To this it shipped ore to ore market sources floodlight, the upgrade to unlimited non-probabilistic spacecraft engines.
【Problem Description】
There are m + 1 planet, from left to right numbered 0 to m, the first planet small odd number 0.
N has the ore, ore body at the i-th unit ore ai, bi on the first planet.
As the spacecraft using an older engine jump every time it can only move from planet to No. x + x 4 stars or No. 7 x + planet. Every planet a little odd will go all the ore mining on the planet, seeking the maximum number of ore can be taken to the odd small.
Note that small odd number m does not have to reach the final planet.
Input Format
The first line of two integers n, m.
Next n lines of two integers ai, bi.
Output Format
Output line an integer representing the required results.
Sample input
3 13
100 4
10 7
1 11
Sample Output
101
prompt
Sample explain]
First from 0 to 4, from 4 to 11 times a second, to a total of 101 units ore mining.
【data range】
20% of the data for n = 1, m <= 10 ^ 5
40% of the data for n <= 15, m <= 10 ^ 5
For 60% of the data m <= 10 ^ 5
To 100% of the data n <= 10 ^ 5, m <= 10 ^ 9,1 <= ai <= 10 ^ 4,1 <= bi <= m