8517: Fall with Full Star

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Fall loves playing games and collecting strange achievements in games. If he doesn't pass a level with full stars, he will feel uncomfortable.

Today, Fall is playing a new game. The game includes n levels without order, which means you can play the levels in any order. However, each level can only be challenged once. During the challenge, Fall may get hurt or pick up rare items. Assuming that before he challenges level i, he has power x, and after he challenges this level, his power will be increased by diAfter that, if his power is higher than or equal to si, he will get a full star in this level.

Initially, Fall has power s0 , he wants to find a challenge order that he can get full star levels as more as possible.

输入格式

The first line contains a single integer T (1T20), the number of test cases. For each test case:

The first line contains two integers n,s0(1n1×105,n106,s01014).

The i-th line of the next n lines contains two integers di,si(di109,si1014), representing the information about the i-th level.

输出格式

For each test case, output a single line containing one integer -- the maximum number of full star levels that Fall can get in a single line.

输入样例 复制

1
3 0
4 5
2 5
1 100

输出样例 复制

2