{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp style\u003d\"text-align: left;\"\u003eIn this problem, you’ll be helping a little bookworm, Kuchu.\u003c/p\u003e\r\n\u003cp style\u003d\"text-align: left;\"\u003eRecently “Omuk book shop” has announced a huge sale on various books. Being a bookworm, Kuchu could not miss this opportunity and went there immediately!\u003c/p\u003e\r\n\u003cp style\u003d\"text-align: left;\"\u003eWhen reached there, she noticed that conditions of the sale are:\u003c/p\u003e\r\n\u003col style\u003d\"text-align: left;\"\u003e\r\n\u003cli\u003eOne must buy exactly B books to get the discount.\u003c/li\u003e\r\n\u003cli\u003eMaximum number of pages in any book is no more than 100.\u003c/li\u003e\r\n\u003c/ol\u003e\u003col style\u003d\"text-align: left;\"\u003e \u003c/ol\u003e\r\n\u003cp style\u003d\"text-align: left;\"\u003eAs she wants to read as much as possible, Kuchu wants to get maximum number of pages satisfying the conditions above. Now she is wondering if there are N books in the store, how many different ways are there to choose exactly B books so that the number of pages is maximum possible.\u003c/p\u003e\r\n\u003cp style\u003d\"text-align: left;\"\u003eNot all books are interesting to little kids, so you are given two information about each book-\u003c/p\u003e\r\n\u003col style\u003d\"text-align: left;\"\u003e\r\n\u003cli\u003eNumber of pages P.\u003c/li\u003e\r\n\u003cli style\u003d\"text-align: left;\"\u003eInterest value V. V is 1 if the book is interesting for kids and 0 otherwise.\u003c/li\u003e\r\n\u003c/ol\u003e\r\n\u003ch3 style\u003d\"text-align: left;\"\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eFirst line contains an integer T, the number of test cases.\u003c/p\u003e\r\n\u003cp\u003eFor each test case, the first line contains two integers N and B as mentioned above. Next N lines contain two integers each P\u003csub\u003ei\u003c/sub\u003e and V\u003csub\u003ei\u003c/sub\u003e, number of pages and interest factor of ith book.\u003c/p\u003e\r\n\u003cp\u003e1 ≤ T ≤ 25\u003c/p\u003e\r\n\u003cp\u003e1 ≤ N ≤ 100,000\u003c/p\u003e\r\n\u003cp\u003e1 ≤ B ≤ N\u003c/p\u003e\r\n\u003cp\u003e1 ≤ P\u003csub\u003ei\u003c/sub\u003e ≤ 100\u003c/p\u003e\r\n\u003cp\u003e0 ≤ V\u003csub\u003ei\u003c/sub\u003e ≤ 1\u003c/p\u003e\r\n\u003ch3 style\u003d\"text-align: left;\"\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each test case, print one integer, the number of different ways to choose exactly B \u003cstrong\u003einteresting books\u003c/strong\u003e from those N books so that the number of pages is maximum possible. As result can be pretty large, print it modulo \u003cstrong\u003e1,000,000,007 (10^9+7)\u003c/strong\u003e.\u003c/p\u003e\r\n\u003ch3 style\u003d\"text-align: left;\"\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cp\u003e2\n2 1\n2 0\n3 0\n5 3\n10 0\n5 1\n2 1\n2 1\n2 1\u003c/p\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cp\u003e0\n3\u003c/p\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}