import java.util.*;
import java.io.*;

public class ornaments_verf {

	static long mod = 1_000_000_007;
	public static void main(String[] args) throws FileNotFoundException{
		Scanner scan = new Scanner(new File("ornaments.in"));
		PrintWriter out = new PrintWriter(new File("ornaments_verf.out"));
		int t = scan.nextInt();
		for(int q = 1; q <= t; q++){
			int n = scan.nextInt();
			if(!(n >= 1 && n <= 20)) problem(q);
			int total = scan.nextInt();
			if(!(total >= 1 && total <= 1000)) problem(q);
			int[] lo = new int[n];
			int[] hi = new int[n];
			for(int i = 0; i < n; i++){
				lo[i] = scan.nextInt();
				hi[i] = scan.nextInt();
				if(lo[i] > hi[i]) problem(q);
				if(!(lo[i] >= 1 && lo[i] <= 1000)) problem(q);
				if(!(hi[i] >= 1 && hi[i] <= 1000)) problem(q);
			}
			long[][] dp = new long[n+1][total+1];
			long[][] pre = new long[n+1][total+1];
			dp[n][total] = 1;
			for(int i = n; i >= 1; i--){
				// compute prefix sums for the dp
				pre[i][0] = dp[i][0];
				for(int j = 1; j <= total; j++){
					pre[i][j] = dp[i][j]+pre[i][j-1];
					pre[i][j] %= mod;
				}

				// use prefix sums to do transition in O(1)
				for(int j = 0; j <= total; j++){
					int min = j+lo[i-1];
					int max = Math.min(total, j+hi[i-1]);
					if(max < min) continue;
					dp[i-1][j] = ((pre[i][max]-pre[i][min-1])%mod+mod)%mod;
				}
			}
			out.println(dp[0][0]);
		}
		out.flush();
	}


	static void problem(int caseID){
		System.out.println("Issue with case "+caseID);
	}
}