import java.util.*;

public class televoteresolver_AN {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int T = s.nextInt();
    for (int tc = 0; tc < T; tc++) {
      int n = s.nextInt();
      long p = s.nextLong();
      long[] j = new long[n];
      long[] t = new long[n];
      for (int i = 0; i < n; i++) {
        j[i] = s.nextLong();
        t[i] = s.nextLong();
      }
      long best = j[n - 1];
      boolean unique = j[n - 1] != j[n - 2];
      int poss = 0;
      int c = 0;
      while (j[poss] + p < best) poss++;
      if (poss == n - 1) {
        System.out.println(0);
        continue;
      }
      while (poss < n) {
        if (j[c] + t[c] == best) {
          unique = false;
        } else if (j[c] + t[c] > best) {
          best = j[c] + t[c];
          unique = true;
        }
        p -= t[c++];
        if (poss < c) poss = c;
        while (poss < n && j[poss] + p < best) poss++;
        if (poss == n - 1) {
          if (best == j[n - 1] && unique) {
            break;
          }
          if (c == n - 1 && j[n - 1] + p > best) {
            unique = true;
            break;
          }
        }
      }
      if (unique) {
        System.out.println(c);
      } else {
        System.out.println(-1);
      }
    }
  }
}
