logo AlgoBeat OnlineJudge
登录 注册

#206222. [NWRRC 2014] Kebab House

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The young man Vahtang Bumerang makes kebabs at the world-famous fast-food chain Kebab House. Each kebab contains many ingredients.

This morning Vahtang has received an order to make kebabs. At first, he should put ingredients to the first kebab, then ingredients in the second one and so on. Vahtang spends one second to put one ingredient to a kebab, so it takes seconds to make the i-th kebab. When he finishes the kebab he immediately proceeds to the next one.

Vahtang often dreams about his lovely boomerang while making kebabs. Each dream takes exactly one second and Vahtang forgets to put one ingredient to kebab during this second. Fortunately, he never dreams twice in any consecutive seconds.

Due to dreams about boomerang, some kebabs may have lesser than the desired number of ingredients, but customers are still happy if the -th kebab has at least ingredients in it.

Vahtang wants to calculate the number of ways to have dream seconds during his work while keeping all customers happy. Can you help him? The real answer may be very huge, so you have to calculate it modulo .

输入格式

The first line of the input file contains two integers and — the number of kebabs and minimal possible time between dream seconds ; .

Each of the next lines contains two integers — the number of ingredients in the -th kebab and the minimum number of ingredients to make the -th customer happy ;

输出格式

The only line of the output file must contain one integer -- the number of ways to distribute dream seconds modulo .

样例

样例输入 1

3 1
4 3
2 2
2 1

样例输出 1

15

数据范围与提示

Time limit: 2 s, Memory limit: 256 MB.