#P1742. CNS Paper

CNS Paper

Description

As the light of mathematics, Little A, a member of ACM team, is in love with prime numbers.

Unlike those who do not study in mathematics, Little A has a specific ability, which is that he can duplicate those items numbered by prime numbers.

One day, his tutor accidentally dropped a series of CNS paper that are all unsigned in front of him and coughed a few times...

For each page in the paper has a value, greedy Little A wants to pick up as much value as possible.(Duplicated counts) Please help him.

Input Format

There will be 22 integers N,V(0N104,0V2×104)N,V(0 \le N \le 10^4, 0 \le V \le 2\times 10^4 ), in the first line, denoting the amount of different papers and the space of Little A's hand.

For the following NN line, each line contains 22 integers viv_i and wiw_i , (0vi,wi1000 \le v_i ,w_i \le 100), denoting space cost and value of each page in the specific paper.

Hint: Papers are numbered from 1N1 \to N.

Output Format

Print the maximum value of the papers Little A can get in a single line.

3 10
1 5
2 5
1 1​
26