Problem: The only difference between easy and hard versions is constraints.

Polycarp loves to listen to music, so he never leaves the player, even on the way home from the university. Polycarp overcomes the distance from the university to the house in exactly T minutes.

In the player, Polycarp stores n songs, each of which is characterized by two parameters: t_i and g_i, where t_i is the length of the song in minutes (1 ≤ t_i ≤ 15), g_i is its genre (1 ≤ g_i ≤ 3).

Polycarp wants to create such a playlist so that he can listen to music all the time on the way from the university to his home, and at the time of his arrival home, the playlist is over. Polycarp never interrupts songs and always listens to them from beginning to end. Thus, if he started listening to the i-th song, he would spend exactly t_i minutes on its listening. Polycarp also does not like when two songs of the same genre play in a row (i.e. successively/adjacently) or when the songs in his playlist are repeated.

Help Polycarpus count the number of different sequences of songs (their order matters), the total duration is exactly T, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different.

Input

The first line of the input contains two integers n and T (1 ≤ n ≤ 15, 1 ≤ T ≤ 225) — the number of songs in the player and the required total duration, respectively.

Next, the n lines contain descriptions of songs: the i-th line contains two integers t_i and g_i (1 ≤ t_i ≤ 15, 1 ≤ g_i ≤ 3) — the duration of the i-th song and its genre, respectively.

Output

Output one integer — the number of different sequences of songs, the total length of exactly T, such that there are no two consecutive songs of the same genre in them and all the songs in the playlist are different. Since the answer may be huge, output it modulo 10^9 + 7 (that is, the remainder when dividing the quantity by 10^9 + 7).

Examples

Input


3 3
1 1
1 2
1 3


Output


6


Input


3 3
1 1
1 1
1 3


Output


2


Input


4 10
5 3
2 1
3 2
5 1


Output


10

Note

In the first example, Polycarp can make any of the 6 possible playlist by rearranging the available songs: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2] and [3, 2, 1] (indices of the songs are given).

In the second example, the first and second songs cannot go in succession (since they have the same genre). Thus, Polycarp can create a playlist in one of 2 possible ways: [1, 3, 2] and [2, 3, 1] (indices of the songs are given).

In the third example, Polycarp can make the following playlists: [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 4], [4, 1], [2, 3, 4] and [4, 3, 2] (indices of the songs are given).

Solution (in JAVA):

Solution:
import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class template {
	public static void main(String[] args) throws Exception {
		new template().run();
	}
	long MOD = 1_000_000_007;
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = f.nextInt(), m = f.nextInt();
		int[] t = new int[n], g = new int[n], c = new int[3];
		for(int i = 0; i < n; i++) {
			t[i] = f.nextInt();
			c[g[i] = f.nextInt()-1]++;
		}
		long[][] dp1 = new long[c[0]+1][m+1];
		long[][][] dp2 = new long[c[1]+1][c[2]+1][m+1];
		dp1[0][0] = 1;
		dp2[0][0][0] = 1;
		for(int i = 0; i < n; i++) {
			if(g[i] == 0) {
				for(int j = dp1.length-2; j >= 0; j--)
					for(int k = m-t[i]; k >= 0; k--)
						dp1[j+1][k+t[i]] = (dp1[j+1][k+t[i]] + dp1[j][k]) % MOD;
			} else if(g[i] == 1) {
				for(int j = dp2.length-2; j >= 0; j--)
					for(int k = dp2[j].length-1; k >= 0; k--)
						for(int l = m-t[i]; l >= 0; l--)
							dp2[j+1][k][l+t[i]] = (dp2[j+1][k][l+t[i]] + dp2[j][k][l]) % MOD;
			} else {
				for(int j = dp2.length-1; j >= 0; j--)
					for(int k = dp2[j].length-2; k >= 0; k--)
						for(int l = m-t[i]; l >= 0; l--)
							dp2[j][k+1][l+t[i]] = (dp2[j][k+1][l+t[i]] + dp2[j][k][l]) % MOD;
			}
		}
		long[][][][] combo = new long[c[0]+1][c[1]+1][c[2]+1][3];
		if(c[0] != 0) combo[1][0][0][0] = 1;
		if(c[1] != 0) combo[0][1][0][1] = 1;
		if(c[2] != 0) combo[0][0][1][2] = 1;
		for(int i = 0; i <= c[0]; i++) {
			for(int j = 0; j <= c[1]; j++) {
				for(int k = 0; k <= c[2]; k++) {
					for(int a = 0; a < 3; a++) {
						if(a != 0 && i < c[0]) combo[i+1][j][k][0] = (combo[i+1][j][k][0] + combo[i][j][k][a] * (i+1) % MOD) % MOD;
						if(a != 1 && j < c[1]) combo[i][j+1][k][1] = (combo[i][j+1][k][1] + combo[i][j][k][a] * (j+1) % MOD) % MOD;
						if(a != 2 && k < c[2]) combo[i][j][k+1][2] = (combo[i][j][k+1][2] + combo[i][j][k][a] * (k+1) % MOD) % MOD;
					}	
				}
			}
		}
		long ans = 0;
		for(int s = 0; s <= m; s++) {
			for(int x = 0; x <= c[0]; x++)
				for(int y = 0; y <= c[1]; y++)
					for(int z = 0;z <= c[2]; z++) {
						ans = (ans + dp1[x][s] * dp2[y][z][m-s] % MOD * ((combo[x][y][z][0] + combo[x][y][z][1] + combo[x][y][z][2]) % MOD) % MOD) % MOD;
					}
		}
		/*
		for(int i = 0; i < dp1.length; i++)
			out.println(Arrays.toString(dp1[i]));
		out.println("-----");
		for(int i = 0; i < dp2.length; i++) {
			for(int j = 0; j < dp2[i].length; j++) 
					out.println(Arrays.toString(dp2[i][j]));
				out.println();
			}
		for(int i = 0; i <= c[0]; i++) for(int j = 0; j <= c[1]; j++) for(int k = 0; k <= c[2]; k++) out.printf("%d %d %d: %d%n", i, j, k, combo[i][j][k][0] + combo[i][j][k][1] + combo[i][j][k][2]); */
		out.println(ans);
		///
		out.flush();
	}
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
}