func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1e4 + 5;   class Matrix {    public:     long long a[3][3];     int n;     void Init(int key) {       memset(a, 0, sizeof a);       if (key)         for (int i = 0; i < n; i++) a[i][i] = 1;     }     Matrix operator*(const Matrix& b) {       Matrix c;       c.n = n;       c.Init(0);       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++)           for (int k = 0; k < n; k++)             c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j] % mod) % mod;       return c;     }     Matrix Power(long long t) {       Matrix ans, p = *this;       ans.n = p.n;       ans.Init(1);       while (t) {         if (t & 1) ans = ans * p;         p = p * p;         t >>= 1;       }       return ans;     }     void Print() {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (j == 0)             printf( %lld , a[i][j]);           else             printf(  %lld , a[i][j]);         }         puts(  );       }     }   };   struct node {     int x, tag;     long long y;     friend bool operator<(const node& a, const node& b) { return a.y < b.y; }   } a[maxn * 2];   long long sum[3], b[3];   void calc(long long n) {     Matrix f, A;     f.Init(0);     A.Init(0);     f.n = A.n = 3;     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         if (sum[j] == 0)           f.a[i][j] = 1;         else           f.a[i][j] = 0;       }     }     f.a[0][2] = f.a[2][0] = 0;     A.a[0][0] = b[0], A.a[0][1] = b[1], A.a[0][2] = b[2];     A = A * f.Power(n);     b[0] = A.a[0][0], b[1] = A.a[0][1], b[2] = A.a[0][2];   }   int main() {     int n;     long long m;     scanf( %d%lld , &n, &m);     int cnt = 0;     for (int i = 1; i <= n; i++) {       int x;       long long l, r;       scanf( %d%lld%lld , &x, &l, &r);       a[++cnt].x = x - 1, a[cnt].y = l - 1, a[cnt].tag = 1;       a[++cnt].x = x - 1, a[cnt].y = r, a[cnt].tag = -1;     }     sort(a + 1, a + cnt + 1);     b[0] = b[2] = 0, b[1] = 1;     long long cur = 1;     for (int i = 1; i <= cnt; i++) {       calc(a[i].y - cur);       cur = a[i].y;       sum[a[i].x] += a[i].tag;     }     calc(m - cur);     printf( %lld n , b[1]);     return 0;   }   