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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion();
        solver.solve(1, in, out);
        out.close();
    }

    static class G1PlaylistForPolycarpEasyVersion {
        static final int mod = (int) 1e9 + 7;

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int t = sc.nextInt();
            G1PlaylistForPolycarpEasyVersion.Song[] songs = new G1PlaylistForPolycarpEasyVersion.Song[n];
            for (int i = 0; i < n; i++) {
                songs[i] = new G1PlaylistForPolycarpEasyVersion.Song(sc.nextInt(), sc.nextInt());
            }
            long ans = 0;
            for (int mask = 1; mask < (1 << n); mask++) {
                int nb = 0;
                int tot = 0;
                int type1 = 0;
                int type2 = 0;
                int type3 = 0;
                for (int j = 0; j < n; j++) {
                    if (((1 << j) & mask) > 0) {
                        nb++;
                        tot += songs[j].l;
                        if (songs[j].type == 1) {
                            type1++;
                        } else if (songs[j].type == 2) {
                            type2++;
                        } else {
                            type3++;
                        }
                    }
                }

                if (tot == t) {
                    long[][][][][] dp = new long[nb + 1][3][type1 + 1][type2 + 1][type3 + 1];
                    boolean[][][][][] go = new boolean[nb + 1][3][type1 + 1][type2 + 1][type3 + 1];
                    if (type1 > 0) {
                        go[1][0][type1 - 1][type2][type3] = true;
                        dp[1][0][type1 - 1][type2][type3] = type1;
                    }
                    if (type2 > 0) {
                        go[1][1][type1][type2 - 1][type3] = true;
                        dp[1][1][type1][type2 - 1][type3] = type2;
                    }
                    if (type3 > 0) {
                        go[1][2][type1][type2][type3 - 1] = true;
                        dp[1][2][type1][type2][type3 - 1] = type3;
                    }
                    for (int i = 0; i < nb; i++) {
                        for (int m = 0; m < 3; m++) {
                            for (int j = 0; j <= type1; j++) {
                                for (int k = 0; k <= type2; k++) {
                                    for (int l = 0; l <= type3; l++) {
                                        if (go[i][m][j][k][l]) {
                                            if (m == 0) {
                                                if (k > 0) {
                                                    dp[i + 1][1][j][k - 1][l] += dp[i][m][j][k][l] * k;
                                                    dp[i + 1][1][j][k - 1][l] %= mod;
                                                    go[i + 1][1][j][k - 1][l] = true;
                                                }
                                                if (l > 0) {
                                                    dp[i + 1][2][j][k][l - 1] += dp[i][m][j][k][l] * l;
                                                    dp[i + 1][2][j][k][l - 1] %= mod;
                                                    go[i + 1][2][j][k][l - 1] = true;
                                                }
                                            } else if (m == 1) {
                                                if (j > 0) {
                                                    dp[i + 1][0][j - 1][k][l] += dp[i][m][j][k][l] * j;
                                                    dp[i + 1][0][j - 1][k][l] %= mod;
                                                    go[i + 1][0][j - 1][k][l] = true;
                                                }
                                                if (l > 0) {
                                                    dp[i + 1][2][j][k][l - 1] += dp[i][m][j][k][l] * l;
                                                    dp[i + 1][2][j][k][l - 1] %= mod;
                                                    go[i + 1][2][j][k][l - 1] = true;
                                                }
                                            } else {
                                                if (j > 0) {
                                                    dp[i + 1][0][j - 1][k][l] += dp[i][m][j][k][l] * j;
                                                    dp[i + 1][0][j - 1][k][l] %= mod;
                                                    go[i + 1][0][j - 1][k][l] = true;
                                                }
                                                if (k > 0) {
                                                    dp[i + 1][1][j][k - 1][l] += dp[i][m][j][k][l] * k;
                                                    dp[i + 1][1][j][k - 1][l] %= mod;
                                                    go[i + 1][1][j][k - 1][l] = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    long toadd = 0;
                    for (int i = 0; i < 3; i++) {
                        toadd += dp[nb][i][0][0][0];
                    }
                    ans += toadd;
                    ans %= (int) 1e9 + 7;
                }
            }
            out.println(ans);
        }

        static class Song {
            int l;
            int type;

            public Song(int x, int y) {
                l = x;
                type = y;
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}