Long puzzle

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You have a one-dimensional puzzle. Every piece of the puzzle can be described by three values: length, type of the left border, and type of the right border. Borders can be one of three types: straight, convex, and concave. Pieces couldn't be reversed, i.e. you can't swap left and right borders of a piece. Any convex border can be connected with any concave border and vice versa. You can't connect pieces by two straight borders.

Figure 1: Example of pieces

You want to connect several (possibly one) pieces one after another in order to get a part of length ll. The left and the right borders of the part should be straight. Find a number of sets of pieces, such that you can build desired part using all pieces from the set. The number could be large, so calculate it modulo 1,000,000,0071\\,000\\,000\\,007. Note that you should find the number of sets of pieces, not the number of different ways of connecting them.

입력

The first line contains two integer numbers nn and ll --- the number of pieces and desired length of a part (1n3001 \le n \le 300, 1l3001 \le l \le 300).

The following nn lines contain a description of the pieces. Every line contains a_ia\_i, b_ib\_i and c_ic\_i --- the length of the piece, type of its left border, and type of its right border, accordingly (1a_il1 \le a\_i \le l; b_i,c_i"in","out","none"b\_i, c\_i \in \\{{\texttt{"in"}}, \texttt{"out"}, \texttt{"none"}\\}). String "in" denotes concave border, "out" --- convex, "none" --- straight.

출력

Output single integer --- the number of sets of pieces, such that you can build desired part using these pieces, modulo 1,000,000,0071\\,000\\,000\\,007.

힌트

Pieces of the puzzle from the first example correspond to the previous picture.

Figure 2: Sets of pieces, such that you can build desired part using them