B. Zmei Gorynich

You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads!

Initially Zmei Gorynich has xx heads. You can deal nn types of blows. If you deal a blow of the ii-th type, you decrease the number of Gorynich's heads by min(di,curX)min(di,curX), there curXcurX is the current number of heads. But if after this blow Zmei Gorynich has at least one head, he grows hihi new heads. If curX=0curX=0 then Gorynich is defeated.

You can deal each blow any number of times, in any order.

For example, if curX=10curX=10, d=7d=7, h=10h=10 then the number of heads changes to 1313 (you cut 77 heads off, but then Zmei grows 1010 new ones), but if curX=10curX=10, d=11d=11, h=100h=100 then number of heads changes to 00 and Zmei Gorynich is considered defeated.

Calculate the minimum number of blows to defeat Zmei Gorynich!

You have to answer tt independent queries.

Input

The first line contains one integer tt (1t1001≤t≤100) – the number of queries.

The first line of each query contains two integers nn and xx (1n1001≤n≤100, 1x1091≤x≤109) — the number of possible types of blows and the number of heads Zmei initially has, respectively.

The following nn lines of each query contain the descriptions of types of blows you can deal. The ii-th line contains two integers didi and hihi (1di,hi1091≤di,hi≤109) — the description of the ii-th blow.

Output

For each query print the minimum number of blows you have to deal to defeat Zmei Gorynich.

If Zmei Gorynuch cannot be defeated print 1−1.

Example
input
Copy
3
3 10
6 3
8 2
1 4
4 10
4 1
3 2
2 6
1 100
2 15
10 11
14 100
output
Copy
2
3
-1
Note

In the first query you can deal the first blow (after that the number of heads changes to 106+3=710−6+3=7), and then deal the second blow.

In the second query you just deal the first blow three times, and Zmei is defeated.

In third query you can not defeat Zmei Gorynich. Maybe it's better to convince it to stop fighting?

 一刀砍死或者多刀加一刀暴击

 

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define PII             pair<int, int>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
using namespace std;
int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod =1e9+7;
const int N = 100005;
//if(x<0 || x>=r || y<0 || y>=c)

inline ll read()
{
    ll x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}
ll gcd(ll m, ll n)
{
    return n == 0 ? m : gcd(n, m % n);
}
ll lcm(ll m, ll n)
{
    return m * n / gcd(m, n);
}
ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}       
int a[35][35];
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        ll n, h;
        cin >> n >> h;
        ll a=0, b=0;
        rep(i, 1, n)
        {
            ll x, y;
            x = read();
            y = read();
            a = max(a, x - y);
            b = max(b, x);
        }
        if (b >= h)
        {
            cout << 1 << endl;
            continue;
        }
        if (a == 0)
            cout << -1 << endl;
        else
            cout << (h - b + a - 1) / a +1<< endl;
    }
    return 0;
}

 

posted @ 2020-06-12 15:15  DeaL57  阅读(230)  评论(0编辑  收藏  举报