func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( inline )   using namespace std;   const int N = 101010, mod = 1e9 + 7;   namespace {   inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }   inline int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }   inline int mul(int x, int y) { return 1LL * x * y % mod; }   }  // namespace   struct edge {     int u, v, w;   } e[N];   int n, K, fac[N];   map<long long, int> f[55][55];   vector<pair<int, int> > adj[N];   vector<int> allu, allv;   long long least[N];   inline void U(int &x, int y) { (x += y) >= mod ? x -= mod : x; }   int main(void) {     scanf( %d%d , &n, &K);     fac[0] = 1;     for (int i = 1; i <= n; i++) {       fac[i] = mul(fac[i - 1], i);     }     for (int i = 1, u, v, w; i <= K; i++) {       scanf( %d%d%d , &u, &v, &w);       e[i] = (edge){u, v, sub(w, 1)};       allu.push_back(u);       allv.push_back(v);     }     sort(allu.begin(), allu.end());     sort(allv.begin(), allv.end());     allu.erase(unique(allu.begin(), allu.end()), allu.end());     allv.erase(unique(allv.begin(), allv.end()), allv.end());     int m = allu.size();     for (int i = 1; i <= K; i++) {       int u = lower_bound(allu.begin(), allu.end(), e[i].u) - allu.begin();       int v = lower_bound(allv.begin(), allv.end(), e[i].v) - allv.begin();       adj[u].push_back((pair<int, int>){v, e[i].w});     }     for (int i = m - 1; ~i; i--) {       least[i] = least[i + 1];       for (auto p : adj[i]) {         least[i] |= 1LL << p.first;       }     }     f[0][0][0] = 1;     for (int i = 0; i < m; i++) {       for (int j = 0; j <= i; j++) {         for (auto p : f[i][j]) {           U(f[i + 1][j][p.first & least[i + 1]], p.second);           for (auto t : adj[i]) {             if (~p.first >> t.first & 1) {               U(f[i + 1][j + 1][(p.first | (1LL << t.first)) & least[i + 1]],                 mul(p.second, t.second));             }           }         }       }     }     int ans = 0;     for (int i = 0; i <= m; i++) {       for (auto p : f[m][i]) {         U(ans, mul(p.second, fac[n - i]));       }     }     cout << ans << endl;     return 0;   }   