Drain Pipes

Count the number of ways to pick quantities of each pipe type, within the given stock, so the chosen pipes sum to exactly x.

Medium5Dynamic programmingArrayCombinatoricsImplementationInterviewNo attempts yetTime limit1sMemory limit128 MB

Problem

Yeongman's house is so old that water keeps leaking from the toilet. Fed up with it, Yeongman decides to fix the drainage himself by joining the spare pipes he has at home.

Cutting a pipe costs far too much, so he must join the leftover pipes as they are to build a pipe of exactly length xx, without cutting any of them. Given the length and quantity of each pipe he owns, count the number of ways to join pipes into a total length of xx. The order in which pipes are joined does not matter.

Input

The first line contains the number of pipe types NN and the desired total length xx. (1N1001 \le N \le 100, 1x100001 \le x \le 10000)

Each of the following NN lines contains a pipe length LiL_i and its quantity CiC_i, separated by a space. (0<Lix0 < L_i \le x, 0<Ci1000 < C_i \le 100) The pipes are given in ascending order of length, and no two types share the same length.

Output

Print the number of ways to build a joined pipe of exactly length xx. The answer never exceeds 21474836472147483647.