#include <bits/stdc++.h>
using namespace std;

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double
#define endl "\n"

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif

// __gcd(x, y)

// idea behind binary search: there is monotonically increasing predicate and range [l, r]. Find
// x in range such that x is smallest value for which predicate holds true.
//            int lo = 1, hi = 1e9;
//            while(lo < hi)
//            {
//                ll mid = (lo+hi) / 2;
//                if(predicate(mid))
//                {
//                    hi = mid;
//                }
//                else
//                {
//                    lo = mid+1;
//                }
//            }
//            assert(lo == hi);

// OR: given monotonically decreasing predicate, find x in range such that x is largest value for
// which predicate holds true.

//int x = 0;
//for(int s = max_step; s >= 1; s /= 2)
//{
//    while(predicate(x+s)) x += s;
//}
// after this, x is the largest value for which predicate is true

// How to calculate mid element:
// floor((l+r) / 2) might overflow, use l + floor((r-l)/2)

//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l < r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// AND
//
//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l <= r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid-1;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// ARE EQUIVALENT

#define ull unsigned long long

void solve() {
    ll n, x;
    cin >> n >> x;

    vector<ll> d(n), h(n);
    bool good = false;
    ll max_diff = 0;
    ll mx_d = 0;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> h[i];
        if(d[i] > h[i]) {
            good = true;
            if(d[i] - h[i] > max_diff) {
                max_diff = d[i] - h[i];
            }

        }
        mx_d = max(mx_d, d[i]);
    }

    if(!good) {
        cout << -1 << endl;
    }
    else {
        ll l = 0, r = x + 1;
        ll ans;
        while(l < r) {
            ll mid = (l + r) / 2;

            if(x - mid * max_diff <= mx_d) {
                r = mid;
                if(x - mid * max_diff <= 0) {
                    ans = mid;
                }
                else {
                    ans = mid + 1;
                }
            }
            else {
                l = mid + 1;
            }
        }

        //        cout << ans << endl;
        for(int i = max(0LL, min(r, l) - 10); i <= min(l, r) + 10; i++) {
            if(x - max_diff * (ll)i <= mx_d) {
                if(x - max_diff * (ll)i <= 0) {
                    cout << i << endl;
                }
                else {
                    cout << i + 1 << endl;
                }
                return;
            }
        }

        assert(false);
        //        int p = -1;
        //        for(int step = x; step >= 1; step /= 2) {
        //            while((p + step) * max_diff < x) p += step;
        //        }

        //        cout << p << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double
#define endl "\n"

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif

// __gcd(x, y)

// idea behind binary search: there is monotonically increasing predicate and range [l, r]. Find
// x in range such that x is smallest value for which predicate holds true.
//            int lo = 1, hi = 1e9;
//            while(lo < hi)
//            {
//                ll mid = (lo+hi) / 2;
//                if(predicate(mid))
//                {
//                    hi = mid;
//                }
//                else
//                {
//                    lo = mid+1;
//                }
//            }
//            assert(lo == hi);

// OR: given monotonically decreasing predicate, find x in range such that x is largest value for
// which predicate holds true.

//int x = 0;
//for(int s = max_step; s >= 1; s /= 2)
//{
//    while(predicate(x+s)) x += s;
//}
// after this, x is the largest value for which predicate is true

// How to calculate mid element:
// floor((l+r) / 2) might overflow, use l + floor((r-l)/2)

//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l < r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// AND
//
//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l <= r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid-1;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// ARE EQUIVALENT

#define ull unsigned long long

void solve() {
    ll n, x;
    cin >> n >> x;

    vector<ll> d(n), h(n);
    bool good = false;
    ll max_diff = 0;
    int max_pos = -1;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> h[i];
        if(d[i] > h[i]) {
            good = true;
            if(d[i] - h[i] > max_diff) {
                max_diff = d[i] - h[i];
                max_pos = i;
            }
        }
    }

    if(!good) {
        cout << -1 << endl;
    }
    else {
        ll l = 0, r = x + 1;
        while(l < r) {
          ll mid = (l + r) / 2;

          if(mid * max_diff + d[max_pos] < x) {
              l = mid + 1;
          }
          else {
              r = mid;
          }
        }

        cout << l + 1 << endl;
//        for(int i = max(0LL, min(r, l) - 10); i <= min(l, r) + 10; i++) {
//            if(x - max_diff * (ll)i <= d[max_pos]) {
//                cout << i + 1 << endl;
//                return;
//            }
//        }

//        assert(false);
//        int p = -1;
//        for(int step = x; step >= 1; step /= 2) {
//            while((p + step) * max_diff < x) p += step;
//        }

//        cout << p << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double
#define endl "\n"

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif

// __gcd(x, y)

// idea behind binary search: there is monotonically increasing predicate and range [l, r]. Find
// x in range such that x is smallest value for which predicate holds true.
//            int lo = 1, hi = 1e9;
//            while(lo < hi)
//            {
//                ll mid = (lo+hi) / 2;
//                if(predicate(mid))
//                {
//                    hi = mid;
//                }
//                else
//                {
//                    lo = mid+1;
//                }
//            }
//            assert(lo == hi);

// OR: given monotonically decreasing predicate, find x in range such that x is largest value for
// which predicate holds true.

//int x = 0;
//for(int s = max_step; s >= 1; s /= 2)
//{
//    while(predicate(x+s)) x += s;
//}
// after this, x is the largest value for which predicate is true

// How to calculate mid element:
// floor((l+r) / 2) might overflow, use l + floor((r-l)/2)

//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l < r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// AND
//
//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l <= r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid-1;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// ARE EQUIVALENT

#define ull unsigned long long

void solve() {
    ll n, x;
    cin >> n >> x;

    vector<ll> d(n), h(n);
    bool good = false;
    ll max_diff = 0;
    int max_pos = -1;
    ll mx_d = 0;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> h[i];
        if(d[i] > h[i]) {
            good = true;
            if(d[i] - h[i] > max_diff) {
                max_diff = d[i] - h[i];
            }
            mx_d = max(mx_d, d[i]);
        }
    }

    if(!good) {
        cout << -1 << endl;
    }
    else {
        ll l = 0, r = x + 1;
        ll ans;
        while(l < r) {
          ll mid = (l + r) / 2;

          if(x - mid * max_diff <= mx_d) {
//              l = mid + 1;
              r = mid;
              ans = mid + 1;
          }
          else {
//              r = mid;
              l = mid + 1;
          }
        }

        cout << ans << endl;
//        for(int i = max(0LL, min(r, l) - 10); i <= min(l, r) + 10; i++) {
//            if(x - max_diff * (ll)i <= d[max_pos]) {
//                cout << i + 1 << endl;
//                return;
//            }
//        }

//        assert(false);
//        int p = -1;
//        for(int step = x; step >= 1; step /= 2) {
//            while((p + step) * max_diff < x) p += step;
//        }

//        cout << p << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double
#define endl "\n"

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif

// __gcd(x, y)

// idea behind binary search: there is monotonically increasing predicate and range [l, r]. Find
// x in range such that x is smallest value for which predicate holds true.
//            int lo = 1, hi = 1e9;
//            while(lo < hi)
//            {
//                ll mid = (lo+hi) / 2;
//                if(predicate(mid))
//                {
//                    hi = mid;
//                }
//                else
//                {
//                    lo = mid+1;
//                }
//            }
//            assert(lo == hi);

// OR: given monotonically decreasing predicate, find x in range such that x is largest value for
// which predicate holds true.

//int x = 0;
//for(int s = max_step; s >= 1; s /= 2)
//{
//    while(predicate(x+s)) x += s;
//}
// after this, x is the largest value for which predicate is true

// How to calculate mid element:
// floor((l+r) / 2) might overflow, use l + floor((r-l)/2)

//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l < r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// AND
//
//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l <= r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid-1;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// ARE EQUIVALENT

#define ull unsigned long long

void solve() {
    ll n, x;
    cin >> n >> x;

    vector<ll> d(n), h(n);
    bool good = false;
    ll max_diff = 0;
    int max_pos = -1;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> h[i];
        if(d[i] > h[i]) {
            good = true;
            if(d[i] - h[i] > max_diff) {
                max_diff = d[i] - h[i];
                max_pos = i;
            }
        }
    }

    if(!good) {
        cout << -1 << endl;
    }
    else {
        ll l = 0, r = x + 1;
        ll ans;
        while(l < r) {
          ll mid = (l + r) / 2;

          if(x - mid * max_diff <= d[max_pos]) {
//              l = mid + 1;
              r = mid;
              ans = mid + 1;
          }
          else {
//              r = mid;
              l = mid + 1;
          }
        }

        cout << ans << endl;
//        for(int i = max(0LL, min(r, l) - 10); i <= min(l, r) + 10; i++) {
//            if(x - max_diff * (ll)i <= d[max_pos]) {
//                cout << i + 1 << endl;
//                return;
//            }
//        }

//        assert(false);
//        int p = -1;
//        for(int step = x; step >= 1; step /= 2) {
//            while((p + step) * max_diff < x) p += step;
//        }

//        cout << p << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double
#define endl "\n"

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i != (int)v.size() - 1)
            os << ", ";
    }
    os << "]\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif

// __gcd(x, y)

// idea behind binary search: there is monotonically increasing predicate and range [l, r]. Find
// x in range such that x is smallest value for which predicate holds true.
//            int lo = 1, hi = 1e9;
//            while(lo < hi)
//            {
//                ll mid = (lo+hi) / 2;
//                if(predicate(mid))
//                {
//                    hi = mid;
//                }
//                else
//                {
//                    lo = mid+1;
//                }
//            }
//            assert(lo == hi);

// OR: given monotonically decreasing predicate, find x in range such that x is largest value for
// which predicate holds true.

//int x = 0;
//for(int s = max_step; s >= 1; s /= 2)
//{
//    while(predicate(x+s)) x += s;
//}
// after this, x is the largest value for which predicate is true

// How to calculate mid element:
// floor((l+r) / 2) might overflow, use l + floor((r-l)/2)

//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l < r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// AND
//
//ll l = 0, r = s.size()-1;
//ll ans = -1;
//while(l <= r)
//{
//    ll mid = l + (r-l) / 2;
//    if(P(mid)) {
//        r = mid-1;
//        ans = mid;
//    }
//    else
//    {
//        l = mid + 1;
//    }
//}
//
// ARE EQUIVALENT

#define ull unsigned long long

void solve() {
    ll n, x;
    cin >> n >> x;

    vector<ll> d(n), h(n);
    bool good = false;
    ll max_diff = 0;
    ll mx_d = 0;
    for(int i = 0; i < n; i++) {
        cin >> d[i] >> h[i];
        if(d[i] > h[i]) {
            good = true;
            if(d[i] - h[i] > max_diff) {
                max_diff = d[i] - h[i];
            }

        }
        mx_d = max(mx_d, d[i]);
    }
    if(mx_d >= x) {
        cout << 1 << endl;
        return;
    }

    if(!good) {
        cout << -1 << endl;
    }
    else {
        ll l = 0, r = x + 1;
        ll ans;
        while(l < r) {
            ll mid = (l + r) / 2;

            if(x - mid * max_diff <= mx_d) {
                r = mid;
                if(x - mid * max_diff <= 0) {
                    ans = mid;
                }
                else {
                    ans = mid + 1;
                }
            }
            else {
                l = mid + 1;
            }
        }

        //        cout << ans << endl;
        for(int i = max(0LL, min(r, l) - 10); i <= min(l, r) + 10; i++) {
            if(x - max_diff * (ll)i <= mx_d) {
                if(x - max_diff * (ll)i <= 0) {
                    cout << i << endl;
                }
                else {
                    cout << i + 1 << endl;
                }
                return;
            }
        }

        assert(false);
        //        int p = -1;
        //        for(int step = x; step >= 1; step /= 2) {
        //            while((p + step) * max_diff < x) p += step;
        //        }

        //        cout << p << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t;
    cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}

	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		for (int j(0); j < n[i] && x[i] > 0; j++) {	//each blow
			if (highest_Blow[i][0] >= x[i]) {
				x[i] = 0;
			}
			else {
				x[i] -= best_Blow[i][0];
				x[i] += best_Blow[i][1];
			}
			num_blows++;
		}
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else
		{
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	/*
	cout << best_Blow[0][0] << " . " << best_Blow[0][1] <<endl;
	cout << highest_Blow[0][0] << " . " << highest_Blow[0][1] << endl;
	*/
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = ceil((float)(x[i] - highest_Blow[i][0]) /(float)(best_Blow[i][0] - best_Blow[i][1])) + 1;
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		for (int j(0); j < n[i] && x[i] > 0; j++) {	//each blow
			if (highest_Blow[i][0] >= x[i]) {
				x[i] = 0;
			}
			else {
				x[i] -= best_Blow[i][0];
				x[i] += best_Blow[i][1];
			}
			num_blows++;
		}
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else
		{
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	/*
	cout << best_Blow[0][0] << " . " << best_Blow[0][1] <<endl;
	cout << highest_Blow[0][0] << " . " << highest_Blow[0][1] << endl;
	*/
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = ceil((float)(x[i] - highest_Blow[i][0]) /(float)(best_Blow[i][0] - best_Blow[i][1])) + 1;
			cout << ((num_blows <= 0) ? 1 : num_blows) << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}

	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			while (x[i] > 0) {	//each blow
				if (highest_Blow[i][0] >= x[i]) {
					x[i] = 0;
				}
				else {
					x[i] -= best_Blow[i][0];
					x[i] += best_Blow[i][1];
				}
				num_blows++;
			}
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}

	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		for (int j(0); x[i] > 0; j++) {	//each blow
			if (highest_Blow[i][0] >= x[i]) {
				x[i] = 0;
			}
			else {
				x[i] -= best_Blow[i][0];
				x[i] += best_Blow[i][1];
			}
			num_blows++;
		}
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else
		{
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = x[i] / (best_Blow[i][0] - best_Blow[i][1]) - highest_Blow[i][0] / (best_Blow[i][0] - best_Blow[i][1]) + 1;
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	cout << best_Blow[0][0] << " . " << best_Blow[0][1] <<endl;
	cout << highest_Blow[0][0] << " . " << highest_Blow[0][1] << endl;
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = x[i] / (best_Blow[i][0] - best_Blow[i][1]) - highest_Blow[i][0] / (best_Blow[i][0] - best_Blow[i][1]) + 1;
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}

	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			while (x[i] > 0) {	//each blow
				if (highest_Blow[i][0] >= x[i]) {
					x[i] = 0;
				}
				else {
					x[i] -= best_Blow[i][0];
					x[i] += best_Blow[i][1];
				}
				num_blows++;
			}
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		int blow;
		best_Blow[i][0] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > best_Blow[i][0]) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}

	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = x[i] / (best_Blow[i][0] - best_Blow[i][1]) - highest_Blow[i][0] / (best_Blow[i][0] - best_Blow[i][1]) + 1;
			/*
			while (x[i] > 0) {	//each blow
				if (highest_Blow[i][0] >= x[i]) {
					x[i] = 0;
				}
				else {
					//x[i] / (best_Blow[i][0] - best_Blow[i][1])
					x[i] -= best_Blow[i][0];
					x[i] += best_Blow[i][1];
				}
				num_blows++;
			}
			*/
			cout << num_blows << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] > x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	/*
	cout << best_Blow[0][0] << " . " << best_Blow[0][1] <<endl;
	cout << highest_Blow[0][0] << " . " << highest_Blow[0][1] << endl;
	*/
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = ceil((float)(x[i] - highest_Blow[i][0]) /(float)(best_Blow[i][0] - best_Blow[i][1])) + 1;
			cout << ((num_blows < 0) ? 0 : num_blows) << endl;
		}
	}
}


#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
	int t;
	cin >> t;

	int *n = new int[t], *x = new int[t];
	int **best_Blow = new int*[t];
	int **highest_Blow = new int*[t];
	bool *can_Kill = new bool[t];
	vector<vector<int>> d(t), h(t);

	for (int i(0); i < t; i++) {
		best_Blow[i] = new int[2];
		highest_Blow[i] = new int[2];
		cin >> n[i];
		cin >> x[i];
		d[i].resize(n[i]);
		h[i].resize(n[i]);
		best_Blow[i][0] = 0;
		best_Blow[i][1] = 0;
		highest_Blow[i][0] = 0;
		can_Kill[i] = false;
		for (int j(0); j < n[i]; j++) {
			cin >> d[i][j];
			cin >> h[i][j];
			if (d[i][j] > h[i][j] || d[i][j] >= x[i]) {
				can_Kill[i] = true;
			}
			if ((d[i][j] - h[i][j]) > (best_Blow[i][0] - best_Blow[i][1])) {
				best_Blow[i][0] = d[i][j];
				best_Blow[i][1] = h[i][j];
			}
			if (d[i][j] > highest_Blow[i][0]) {
				highest_Blow[i][0] = d[i][j];
				highest_Blow[i][1] = h[i][j];
			}
		}
	}
	/*
	cout << best_Blow[0][0] << " . " << best_Blow[0][1] <<endl;
	cout << highest_Blow[0][0] << " . " << highest_Blow[0][1] << endl;
	*/
	int num_blows(0);
	for (int i(0); i < t; i++) { //each querry
		num_blows = 0;
		if (!can_Kill[i]) {
			cout << -1 << endl;
		}
		else {
			num_blows = ceil((float)(x[i] - highest_Blow[i][0]) /(float)(best_Blow[i][0] - best_Blow[i][1])) + 1;
			cout << ((num_blows <= 0) ? 1 : num_blows) << endl;
		}
	}
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && x > maxD) printf("-1\n");
		else {
			if (maxD => x) {
				printf("1");
			}
			else if (maxD > 0) {
				lld R = x - maxD;
				lld result = (R / maxBenefit) + (R % maxBenefit > 0) + 1;
				printf("%lld", result);
			}
			else {
				lld result = (x / maxBenefit) + (x % maxBenefit > 0);
				printf("%lld", result);
			}
			printf("\n");
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && x > maxD) printf("-1\n");
		else {
			if (maxD >= x) {
				printf("1");
			}
			else if (maxD > 0) {
				lld R = x - maxD;
				lld result = (R / maxBenefit) + (R % maxBenefit > 0) + 1;
				printf("%lld", result);
			}
			else {
				lld result = (x / maxBenefit) + (x % maxBenefit > 0);
				printf("%lld", result);
			}
			printf("\n");
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && x > maxD) printf("-1");
		else {
			if (maxD > x) {
				printf("1");
			}
			else if (maxD > 0) {
				lld R = x - maxD;
				lld result = (R / maxBenefit) + (R % maxBenefit > 0) + 1;
				printf("%lld", result);
			}
			else {
				lld result = (x / maxBenefit) + (x % maxBenefit > 0);
				printf("%lld", result);
			}
			printf("\n");
		}
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0) printf("-1");
		else {
			lld result = x / maxBenefit;
			if (x % maxBenefit) {
				result--;
				lld last = x % maxBenefit + maxBenefit;
				if (last <= maxD) result += 1;
				else result += 2;
			}

			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0) printf("-1");
		else {
			lld reminder = ((maxD > 0) ? x - maxD : x);
			lld result = (reminder / maxBenefit) + ((reminder % maxBenefit) ? 1 : 0) + 1;
			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && maxD <= 0) printf("-1");
		else {
			lld reminder = x - maxD;
			lld result = (reminder / maxBenefit) + ((reminder % maxBenefit) ? 1 : 0) + 1;
			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0) printf("-1");
		else {
			lld reminder = ((maxD > 0) ? x - maxD : x);
			lld result = (reminder / maxBenefit) + ((reminder % maxBenefit) ? 1 : 0) + (maxD > 0 ? 1 : 0);
			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && x > maxD) printf("-1\n");
		else {
			if (maxD > x) {
				printf("1");
			}
			else if (maxD > 0) {
				lld R = x - maxD;
				lld result = (R / maxBenefit) + (R % maxBenefit > 0) + 1;
				printf("%lld", result);
			}
			else {
				lld result = (x / maxBenefit) + (x % maxBenefit > 0);
				printf("%lld", result);
			}
			printf("\n");
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0) printf("-1");
		else {
			lld reminder = x - maxD;
			lld result = (reminder / maxBenefit) + ((reminder % maxBenefit) ? 1 : 0) + 1;
			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <cstdio>
using namespace std;

typedef long long int lld;

int main() {
	int T;
	scanf("%d", &T);

	for (int t = 0; t < T; t++) {
		lld n, x;
		scanf("%lld %lld", &n, &x);

		lld maxD = -1;
		lld maxBenefit = -1;
		for (int i = 0; i < n; i++) {
			lld d, h;
			scanf("%lld %lld", &d, &h);
			if (maxD < d) maxD = d;
			if (maxBenefit < d - h) maxBenefit = d - h;
		}

		if (maxBenefit <= 0 && x > maxD) printf("-1");
		else {
			lld reminder = ((maxD > 0) ? x - maxD : x);
			lld result = (reminder / maxBenefit) + ((reminder % maxBenefit) ? 1 : 0) + (maxD > 0 ? 1 : 0);
			printf("%lld\n", result);
		}
	}

	return 0;
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first<=0 && raz>0 && mxx<x) {
        cout<<(x/raz)+(!(x%raz))<<'\n';}
    else {
    ll ans = 0;
    ll u = (x/a[0].first);
    ll kit = (mxx/a[0].first);
    ans=(u-kit);
    if (ans) cout<<ans+1<<'\n';
        else cout<<ans+2<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = a[0].first;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<ans<<'\n';
    }}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0+1<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = 1e9;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<ans<<'\n';
    }
    else {
    cout<<(x/raz)+(!(x%raz))<<'\n';
    }}return 0;
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = 1e9;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<ans<<'\n';
    }
    else {
    cout<<(x/raz)+(!(x%raz))<<'\n';
    }}return 0;
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = 1e9;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<min(ans,(x/raz)+(!(x%raz)));<<'\n';
    }
    else {
    cout<<(x/raz)+(!(x%raz))<<'\n';
    }}return 0;
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = 1e9;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<min(ans,(x/raz)+(!(x%raz));<<'\n';
    }
    else {
    cout<<(x/raz)+(!(x%raz))<<'\n';
    }}return 0;
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first<=0 && raz>0 && mxx<x) {
        cout<<(x/raz)+(!(x%raz))<<'\n';}
    else {
    ll ans = x;
    cout<<(ans/a[0].second)+((ans%a[0].second)>0)<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        mxx = max(mxx,b[i].first);
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<0 && mxx>=x) {cout<<1<<'\n';}
    else if (mxx>=x) {cout<<1<<'\n';}
    else {
    ll qt = x/max(a[0].first,mxx);
        if (x%(max(a[0].first,mxx))) qt++;
    cout<<qt<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        mxx = max(mxx,b[i].first);
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<0 && mxx>=x) {cout<<1<<'\n';}
    else if (mxx>=x) {cout<<1<<'\n';}
    else {
    ll qt = x/a[0].first;
    if ((x%a[0].first)>0) qt++;
    ll h = ((x-a[0].first)/mxx)+1;
        if ((x-a[0].first)%mxx) h++;
    cout<<min(qt,h)<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        mxx = max(mxx,b[i].first);
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else {
    ll qt = x/max(a[0].first,mxx);
    qt++;
    cout<<qt<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first<=0 && raz>0 && mxx<x) {
        cout<<(x/raz)+(!(x%raz))<<'\n';}
    else {
    ll ans = x;
        bool fig = true;
        ll ft = 0;
        while (fig) {
            ll reserv = ans;
            ans-=a[0].second;
            ft++;
            if (ans<0) break;
            if (ans<mxx) {ans = 0;ft++;break;}
            ans = reserv-a[0].first;
        }
        cout<<ft<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first<=0 && raz>0 && mxx<x) {
        cout<<(x/raz)+(!(x%raz))<<'\n';}
    else {
    ll ans = x;
    cout<<(ans/a[0].second)+1<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        mxx = max(mxx,b[i].first);
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else {
    ll qt = x/max(a[0].first,mxx);
        if (x%(max(a[0].first,mxx))) qt++;
    cout<<qt<<'\n';
}
}
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0)
#define Belarus cin.tie(0)
#define WOW cout.tie(0)
#define Super int main()
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
Super {
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
IOS;
Belarus;
WOW;
ll test;
cin>>test;
while (test--)
{
    ll n,x;
    cin>>n>>x;
    vector <pair <ll,ll> > b(n);
    vector <pair <ll,ll> > a(n);
    ll mxx = 0;
    ll pur = 0;
    ll raz = 0;
    for (int i = 0;i < n;i++)
    {
        cin>>b[i].first>>b[i].second;
        if (mxx<b[i].first) mxx = max(mxx,b[i].first),pur=i,raz=b[i].first-b[i].second;
        a[i].first = (b[i].first-b[i].second);
        a[i].second = b[i].first;
    }
    sort(a.rbegin(),a.rend());
    if (a[0].first<0 && mxx<x) {cout<<-1<<'\n';}
    else if (a[0].first<=0 && raz<=0 && mxx<x) {
        cout<<-1<<'\n';}
    else if (a[0].first<=0 && mxx>=x) {
        cout<<0<<'\n';}
    else if (a[0].first>0) {
        ll l = 0;
        ll r = 1e9;
        while (l+1<r)
        {
            ll mid = (l+r)/2;
            if ((x-(a[0].first*mid))<=mxx) r = mid;
            else l = mid;}
        ll ans = 0;
        for (int j = l;j<=r;j++)
            if ((x-(a[0].first*j))<=mxx) {ans = j + 1;break;}
        cout<<min(ans,(x/raz)+(!(x%raz)))<<'\n';
    }
    else {
    cout<<(x/raz)+(!(x%raz))<<'\n';
    }}return 0;
/*
Добрый вечер!
*/
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      ll diff = (a - b);
      ll num = x / diff;
      ll curAns;
      if(x - (max(num-1, 0ll) * a) + (max(num - 2, 0ll) * b) <= 0) {
        curAns = num;
      } else if(x - (num * a) + (max(num - 1, 0ll) * b) <= 0) {
        curAns = num;
      } else {
        ++num;
        if(x - (num * a) + (max(num - 1, 0ll) * b) <= 0) {
          curAns = num;
        }
      }
      ans = min(ans, curAns);
    }
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      ll diff = (a - b);
      ll num = ceil((double)x / (double)diff);
      if(num >= 2) {
        if((num-1) * a - (num - 2) * b >= x)
          --num;
      }
      ans = min(ans, num);
    }
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
unordered_map<ll, bool> mp;

int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, a, b;
    cin >> n >> x;
    vec.clear();
    mp.clear();
    bool done = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        done = 1;
        continue;
      }
      if(b >= a)
        continue;
      vec.push_back({a, b});
    }
    if(done) {
      cout << 1 << '\n';
      continue;
    }
    queue<ll> q;
    q.push(x);
    ll lvl = 0, sz;
    while(!q.empty() && !done) {
      sz = q.size();
      ++lvl;
      while(sz-- && !done) {
        ll it = q.front();
        q.pop();
        for (int i = 0; i < (int)vec.size() && !done; ++i) {
          if(it - vec[i].first <= 0) {
            cout << lvl << '\n';
            done = 1;
          }
          ll val = it - vec[i].first + vec[i].second;
          if(mp[val] == 1)
            continue;
          mp[val] = 1;
          q.push(it - vec[i].first + vec[i].second);
        }
      }
    }
    if(done)
      continue;
    cout << -1 << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
map<ll, bool> mp;

int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    mp.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      vec.push_back({a, b});
    }
    queue<ll> q;
    q.push(x);
    ll lvl = 0, sz;
    bool done = 0;
    while(!q.empty() && !done) {
      sz = q.size();
      ++lvl;
      while(sz-- && !done) {
        ll it = q.front();
        q.pop();
        for (int i = 0; i < vec.size() && !done; ++i) {
          if(it - vec[i].first <= 0) {
            cout << lvl << '\n';
            done = 1;
          }
          ll val = it - vec[i].first + vec[i].second;
          if(mp.find(val) != mp.end())
            continue;
          mp[val] = 1;
          q.push(it - vec[i].first + vec[i].second);
        }
      }
    }
    if(done)
      continue;
    cout << -1 << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = OO, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      vec.push_back({a, b});
    }
    for(pair<ll, ll> it: vec) {
      ll start = 1, end = 1e9 + 9, mid, bestAns = OO;
      while(start <= end) {
        mid = start + (end - start) / 2;
        ll dmg = (it.first * mid);
        dmg -= (it.second * (mid - 1));
        if(dmg >= x) {
          bestAns = min(bestAns, mid);
          end = mid - 1;
        } else {
          start = mid + 1;
        }
      }
      ans = min(ans, bestAns);
    }
    if(ans == OO)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
vector<ll> yaa;

int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = OO, a, b;
    cin >> n >> x;
    vec.clear();
    ll mx = -1, mxA = -1, yaa = -1;
    pair<ll, ll > it;
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(b >= a) {
        yaa = max(yaa, a);
        continue;
      }
      if(a - b > mx || (a - b >= mx && a > mxA)) {
        mx = (a - b);
        mxA = a;
        it = {a, b};
      }
      yaa = max(yaa, a);
    }
    ll start = 0, end = 1e9 + 9, mid, bestAns = OO;
    while(start <= end) {
      mid = start + (end - start) / 2;
      ll dmg = (it.first * mid);
      dmg -= (it.second * (mid));
      if(dmg + yaa >= x) {
        bestAns = min(bestAns, mid + 1);
        end = mid - 1;
      } else {
        start = mid + 1;
      }
    }
    ans = min(ans, bestAns);
    if(ans == OO)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      ll diff = (a - b);
      ll num = round((double)x / (double)diff);
      ll curAns;
      ans = min(ans, num);
    }
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      ll diff = (a - b);
      ll num = x / diff;
      ll curAns;
      if(x - (num * a) + (max(num - 1, 0ll) * b) <= 0) {
        curAns = num;
      } else {
        ++num;
        if(x - (num * a) + (max(num - 1, 0ll) * b) <= 0) {
          curAns = num;
        }
      }
      ans = min(ans, curAns);
    }
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = OO, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(b >= a) {
        if(a >= x)
          ans = 1;
        continue;
      }
      vec.push_back({a, b});
    }
    if(ans == 1) {
      cout << ans << '\n';
      continue;
    }
    for(pair<ll, ll> it: vec) {
      ll start = 1, end = 1e9 + 9, mid, bestAns = OO;
      while(start <= end) {
        mid = start + (end - start) / 2;
        ll dmg = (it.first * mid);
        dmg -= (it.second * (mid - 1));
        if(dmg >= x) {
          bestAns = mid;
          end = mid - 1;
        } else {
          start = mid + 1;
        }
      }
      ans = min(ans, bestAns);
    }
    if(ans == OO)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec;
int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll n, x, ans = OO, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      vec.push_back({a, b});
    }
    for(pair<ll, ll> it: vec) {
      ll start = 1, end = 1e9 + 9, mid, bestAns = OO;
      while(start <= end) {
        mid = start + (end - start) / 2;
        ll dmg = (it.first * mid);
        dmg -= (it.second * (mid - 1));
        if(dmg >= x) {
          bestAns = mid;
          end = mid - 1;
        } else {
          start = mid + 1;
        }
      }
      ans = min(ans, bestAns);
    }
    if(ans == OO)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<pair<ll, ll>> vec;

ll mem[109][109], n;
ll solve(int idx, int prv, ll dmg) {
  if(dmg - vec[prv].second <= 0) {
    return 0;
  }
  ll& ret = mem[idx][prv];
  if(~ret)
    return ret;
  ret = inf;
  for (int i = 0; i < n; ++i) {
    ret = min(ret, solve(idx+1, i, dmg - vec[i].first + vec[i].second) + 1);
  }
  return ret;
}

int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      vec.push_back({a, b});
    }
    n = vec.size();
    vec.push_back({0, 0});
    clr(mem, -1);
    ans = solve(0, n, x);
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
#define all(v) ((v).begin()),((v).end())
#define read freopen("input.in", "rt", stdin);
#define write freopen("output.in", "wt", stdout);
#define fastIO cout << fixed << setprecision(0), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 1e6 + 9, OO = 1e9 + 9, MOD = 1e9 + 7;
const ll inf = 1e18;

vector<pair<ll, ll>> vec;

ll mem[109][109][109], n;
ll solve(int idx, int prv, int cur, ll dmg) {
  if(dmg - vec[cur].second <= 0) {
    return 0;
  }
  ll& ret = mem[idx][prv][cur];
  if(~ret)
    return ret;
  ret = inf;
  for (int i = 0; i < n; ++i) {
    ret = min(ret, solve(idx+1, cur, i, dmg - vec[i].first + vec[i].second) + 1);
  }
  return ret;
}

int main() {
  fastIO
  int t;
  cin >> t;
  while(t--) {
    ll x, ans = 1e18, mx = 1e18, a, b;
    cin >> n >> x;
    vec.clear();
    for (int i = 0; i < n; ++i) {
      cin >> a >> b;
      if(a >= x) {
        ans = 1;
        continue;
      }
      if(b >= a)
        continue;
      vec.push_back({a, b});
    }
    n = vec.size();
    vec.push_back({0, 0});
    clr(mem, -1);
    ans = solve(0, n, n, x);
    if(ans == mx)
      ans = -1;
    cout << ans << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        ll y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(B[0]>curX)
        {
            cout<<1<<endl;
            continue;
        }
        l
        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        l y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(B[0]>=curX)
        {
            cout<<1<<endl;
            continue;
        }

        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        ll y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(B[0]>curX)
        {
            cout<<1<<endl;
            continue;
        }

        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        l y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
        }
        sort(A,A+n,greater<ll>());
        if(A[0]<0)
        {
            cout<<-1<<endl;
            continue;
        }
        if(curX%A[0]==1)
        cout<<curX/A[0]<<endl;
        else if(curX%A[0]!=0)
        cout<<curX/A[0] + 1<<endl;
        else
        cout<<curX/A[0]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
        }
        sort(A,A+n,greater<ll>());
        if(A[0]<0)
        {
            cout<<-1<<endl;
            continue;
        }
        if(curX%A[0]!=0)
        cout<<curX/A[0] + 1<<endl;
        else
        cout<<curX/A[0]<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(B[0]>curX)
        {
            cout<<1<<endl;
            continue;
        }

        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        ll y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
        }
        sort(A,A+n,greater<ll>());
        cout<<ceil(curX/A[0])<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(A[0]<0)
        {
            cout<<-1<<endl;
            continue;
        }
        ll y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n,curX,d,h;
        cin>>n>>curX;
        ll A[n];ll B[n];
        for(int i=0;i<n;i++)
        {
            cin>>d>>h;
            A[i]=d-h;
            B[i]=d;
        }
        sort(A,A+n,greater<ll>());
        sort(B,B+n,greater<ll>());
        if(A[0]<=0)
        {
            cout<<-1<<endl;
            continue;
        }
        if(B[0]>curX)
        {
            cout<<1<<endl;
            continue;
        }
        ll y=curX-B[0];
        if(y%A[0]==0)
        cout<<y/A[0]+1<<endl;
        else
        cout<<y/A[0]+2<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c <= 0&&ma<x)cout << -1 << endl;
		else
		{
			int ans = (x - ma) / w[0].c;
			if ((x - ma) % w[0].c > 0)ans++;
			if (ans < 0)ans = 0;
			cout << ans + 1 << endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c <= 0&&ma<x)cout << -1 << endl;
		else
		{
			int ans = (x - ma) / w[0].c;
			if ((x - ma) % w[0].c > 0)ans++;
			cout << ans + 1 << endl;
		}

	}
	return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<functional>
using namespace std;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;

int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int n, x;
		cin >> n >> x;
		vector< pair<int, int> >vec;
		int mx = 0;
		int mx_d = 0;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			int d, h;
			cin >> d >> h;
			vec.emplace_back(d, h);
			mx = max(d, mx);
			mx_d = max(d - h, mx_d);
			if (d > h) {
				flag = true;
			}
		}
		if (mx_d <= 0) {
			cout << -1 << endl;
			continue;
		}
		int ans = 0;
		x -= mx;
		ans = 1;
		if (x > 0) {
			ans += (x + mx_d - 1) / mx_d;
		}
		cout << ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int t;
    cin >> t;
    while (t--) {
        int n, x;
        cin >> n >> x;
        int res = INT_MAX;
        int a = INT_MAX, b = INT_MAX;
        for (int i = 1; i <= n; i++) {
            int d, h;
            cin >> d >> h;
            a = min(a, -d);
            b = min(b, -d + h);
        }
        a = -a;
        b = -b;
        x -= a;
        if (x <= 0) {
            puts("1");
        } else {
            if (b > 0) {
                printf("%d\n", 1 + (x + b - 1) / b);
            } else {
                puts("-1");
            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c <= 0)cout << -1 << endl;
		else
		{
			int ans = (x - ma) / w[0].c;
			if ((x - ma) % w[0].c > 0)ans++;
			cout << ans + 1 << endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c<=0)cout << -1<<endl;
		else
		{
			int ans = (x - ma) / w[0].c ;
			if ((x - ma) % w[0].c > 0)ans++;
			cout << ans+1 << endl;
		}

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()

int main()
{
    fast;
	ll t;
	cin >> t;
	while(t--)
	{
		ll n,x,w1=0,w2=0,m1=0,m2=0;
		cin >> n >> x;
		fr(i,0,n)
		{
			ll x1,x2;
			cin >> x1 >> x2;
			if(x1>=x)
				w1=1;
			if(x1>x2)
				w2=1;
			m1=max(m1,x1-x2);
			m2=max(m2,x1);
		}
		if(w1)
			cout << 1 << endl;
		else if(w2==0)
			cout << -1 << endl;
		else
		{
			ll y=(x-m2+m1-1)/m1;
			cout << y+1 << endl;
		}
	}
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
string s;
int ppp(long long& l, long long& r)
{
	long long ans = 0;
	long long p = 1;
	for (int i = r; i >= l; i--)
	{
		ans = ans + p * (long long)(s[i] - '0');
		p *= 2ll;
	}
	return ans;
}
int main() {
	int q;
	cin >> q;
	vector< pair<int, int> >v;
	for (int i = 0; i < q; i++) {
		int n, x;
		cin >> n >> x;
		v.clear();
		int maxs = 0;
		int maxd = 0;
		bool flag = false;
		for (int i = 0; i < n; i++) {
			int d, h;
			cin >> d >> h;
			v.push_back(make_pair(d, h));
			maxs = max(d, maxs);
			maxd = max(d - h, maxd);
			if (d > h) {
				flag = true;
			}
		}
		if (maxd <= 0) {
			cout << -1 << endl;
			continue;
		}
		long long ans = 0;
		x -= maxs;
		ans = 1;
		if (x > 0) {
			ans += (x + maxd - 1) / maxd;
		}
		cout << ans << endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c <= 0&&ma<x)cout << -1 << endl;
		else
		{
			if (ma < x) {
				cout << 1 << endl;
				continue;
			}
			int ans = (x - ma) / w[0].c;
			if ((x - ma) % w[0].c > 0)ans++;
			cout << ans + 1 << endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss
{
	int a, b, c;
}w[101];
bool cmp(struct ss a, struct ss b) { return a.c > b.c; }
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, x;
		cin >> n >> x;
		int i;
		int ma = 0;
		for (i = 0; i < n; i++)
		{
			int a, b;
			cin >> a >> b;
			w[i].a = a;
			w[i].b = b;
			w[i].c = a - b;
			ma = max(ma, w[i].a);
		}
		sort(w, w + n, cmp);
		int ans = 0;
		if (w[0].c <= 0&&ma<x)cout << -1 << endl;
		else
		{
			if (ma >= x) {
				cout << 1 << endl;
				continue;
			}
			int ans = (x - ma) / w[0].c;
			if ((x - ma) % w[0].c > 0)ans++;
			cout << ans + 1 << endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
	int T;
	cin >> T;
	while (T--) {
		long long k, b,x,l;
		long long max1=0, max2=0;
		cin >> k>>l;
		for (int i = 0; i < k; i++) {
			cin >> b >> x;
			if (b - x > max1) {
				max1 = b - x;
			}
			if (b > max2)max2 = b;
		}
		long long m = 0;
		if (max1 == 0 && max2 < l)cout << "-1" << endl;
		else if (max2 >= l)cout << "1" << endl;
		else {
			m = l / max1+1;
			int p = l % max1;
			for (int i = 1;; i++) {
				if (p + i * max1 <= max2) {
					m--;
				}
				else break;
			}
			cout << m << endl;
		}
	}
	return 0;
}


    #include <iostream>

    using namespace std;

    int main()
    {
        int x,n,m=0,m1=0,x1=0,k=0,t;
        cin>>t;
        for (int i=0;i<t;i++)
        {
            cin>>n>>x;
            for (int j=0;j<n;j++)
            {   int a[n];//massiv for damage
                int b[n];//massive for heads
            cin>>a[j]>>b[j];
            if (a[j]>m) m=a[j];
            if ((a[j]-b[j])>m1&&(a[j]-b[j])>0) m1=a[j]-b[j];
            }
            x1=x-m;
            k++;
            if (x1!=0&&m1==0) cout<<-1<<endl;
            else{
            if (x1!=0)
            {if (x1<m1)
            {
                k++;
            }else k=k+((x1/m1)+1);}
            cout<<k<<endl;}
            x1=0;
            k=0;
            m=0;
            m1=0;
        }
    }


#include <iostream>

using namespace std;

int main()
{int x,n,m,m1,x1,k,t;
m=0;
m1=0;
k=0;
cin>>t;
for (int i=0;i<t;i=i+1)
{cin>>n>>x;
for (int j=0;j<n;j=j+1)
{int a[n];//massiv for damage
int b[n];//massive for heads
cin>>a[j]>>b[j];
if (a[j]>m) m=a[j];
if ((a[j]-b[j])>m1&&(a[j]-b[j])>0) m1=a[j]-b[j];}
x1=x-m;
if (x1!=0&&m1==0) cout<<-1<<endl;
else{k=(x1/m1)+1;
cout<<k<<endl;
}x1=0;
k=0;
m=0;
m1=0;}
return 0;}


import java.io.PrintWriter

fun main() {
    val t = readInt()
    val out = PrintWriter(System.out);
    for (x in t downTo 1) {
        val (n, k1, k2) = readInts()
        val s = readStrings().get(0)
        val a = IntArray(s.length)
        var prev = -1
        for (i in 0 until s.length) {
            if (s[i] == '0')
                a[i] = 0
            else {
                if (prev == -1) {
                    a[i] = k1
                } else if (prev == 0) {
                    a[i] = k1
                } else {
                    val value = k2 - prev
                    if (value > k1)
                        a[i] = k1
                    else
                        a[i] = value
                }
            }
            prev = a[i]
        }
        var sum = 0L
        for (i in 0 until a.size)
            sum += a[i]
        out.println(sum)
    }
    out.flush()
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints