func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, m, a[100010], l[100010], r[100010], LS[100010], T;   int G[100010][10];   struct MAT {     int data[10][10];     MAT() { memset(data, 0, sizeof(data)); }     MAT operator*(const MAT& ma) const {       MAT ret;       for (int i = 1; i <= 3; ++i)         for (int j = 1; j <= 3; ++j)           for (int k = 1; k <= 3; ++k)             ret.data[i][j] =                 (ret.data[i][j] + 1ll * data[i][k] * ma.data[k][j]) % 1000000007;       return ret;     }   };   MAT A;   int main() {     scanf( %lld%lld , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %d%lld%lld , &a[i], &l[i], &r[i]);       LS[++T] = l[i], LS[++T] = r[i] + 1;     }     LS[++T] = 2, LS[++T] = m + 1;     sort(LS + 1, LS + T + 1);     T = unique(LS + 1, LS + T + 1) - LS - 1;     for (int i = 1; i <= n; ++i) {       l[i] = lower_bound(LS + 1, LS + T + 1, l[i]) - LS;       r[i] = lower_bound(LS + 1, LS + T + 1, r[i] + 1) - LS;       G[l[i]][a[i]]++, G[r[i]][a[i]]--;     }     for (int i = 1; i <= 3; ++i) A.data[i][i] = 1;     for (int i = 1; i < T; ++i) {       for (int j = 1; j <= 3; ++j) G[0][j] += G[i][j];       MAT I;       for (int j = 1; j <= 3; ++j)         for (int k = max(1, j - 1); k <= min(3, j + 1); ++k)           if (!G[0][k]) I.data[j][k] = 1;       long long len = LS[i + 1] - LS[i];       for (; len; len >>= 1, I = I * I)         if (len & 1) A = A * I;     }     printf( %d , A.data[2][2]);     return 0;   }   