func_code_string: #include <bits/stdc++.h>   #include <iostream>   using namespace std;   const int MAX_N = 1e5 + 5;   const int MAX_L = 20; // ~ Log N   const long long MOD = 1e9 + 7;   const long long INF = 1e9 + 7;   typedef long long ll;      const int mx = 5e6 + 23;   const ll mod = 1e9 + 7;      int a[mx], team[mx], org[mx];   int n, m;   ll s[2];      int seed, base;   int rnd(){     int ret = seed;     seed = (1ll * seed * base + 233) % mod;     return ret;   }      void solve() {     cin>>n>>m;     int lastp = 0;     for(int i=1,p,k,b,w;i<=m;i++){       cin>>p>>k>>b>>w;       seed = b;       base = w;       for(int j=lastp;j<p;j++){         team[j] = rnd() % 2;         s[team[j]] += (org[j] = a[j] = rnd() % k + 1);       }       lastp = p;     }     int st = 0;     if(s[team[0]] > s[!team[0]]){       s[team[0]]--;       a[0]--;       while(team[0] == team[st] && st < n)         st++;     }     int cur = st;     ll sum = 0;     if(st != n)       while(s[team[st]]){         if(team[cur] == team[st]){           sum += a[cur];           a[cur] = 0;         }         else{           ll d = min(1ll * a[cur], sum);           s[team[st]] -= d;           sum -= d;           a[cur] -= d;         }         cur = (cur + 1 == n ? 0 : cur + 1);       }       ll ans = 1;       for(int i=0;i<n;i++){         ll qwq = (((org[i] - a[i]) ^ (1ll * (i + 1) * (i + 1))) + 1) % mod;         ans = ans * qwq % mod;       }       cout<<ans;   }   int main()    {       ios_base::sync_with_stdio(false);cin.tie(NULL);             #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       freopen( error.txt ,  w , stderr);       freopen( output.txt ,  w , stdout);       #endif             int t=1;     // cin>>t;       while(t--)       {          solve();         // cout<<  n ;       }             cerr<< time taken :  <<(float)clock()/CLOCKS_PER_SEC<<  secs <<endl;       return 0;    }    