#include <bits/stdc++.h>   using namespace std;   const int K = 5;   const int Mod = 1e9 + 7;   void add(int &a, long long b) { a = (a + b) % Mod; }   long long encode(const vector<int> &p) {     assert(p.size() == K);     long long x = 0;     for (auto i : p) {       x = (x << K) + i;     }     return x;   }   bool insert(vector<int> &p, int x) {     int b = -1;     for (int i = K - 1; i >= 0; i--) {       if (x >> i & 1) {         if (p[i] != 0)           x ^= p[i];         else if (b == -1)           b = i;       }     }     if (b == -1) return false;     p[b] = x;     for (int i = b + 1; i < K; i++) {       if (p[i] >> b & 1) p[i] ^= x;     }     return true;   }   vector<vector<int> > spaces;   unordered_map<long long, int> id;   int basic[1 << K];   int sum[400][400], tot;   int comb(int a, int b) {     vector<int> p = spaces[a];     for (auto x : spaces[b]) {       if (x > 0 && !insert(p, x)) return -1;     }     long long c = encode(p);     assert(id.count(c));     return id[c];   }   void build() {     spaces.push_back(vector<int>(K, 0));     id[0] = 0;     basic[0] = -1;     for (int x = 1; x < (1 << K); x++) {       int sz = spaces.size();       basic[x] = sz;       for (int i = 0; i < sz; i++) {         vector<int> p = spaces[i];         if (insert(p, x)) {           long long c = encode(p);           if (!id.count(c)) {             id[c] = spaces.size();             spaces.push_back(p);           }         }       }     }     tot = spaces.size();     for (int i = 0; i < tot; i++)       for (int j = 0; j < tot; j++) sum[i][j] = comb(i, j);   }   const int N = 1e5 + 10;   vector<pair<int, int> > G[N];   void add_edge(int u, int v, int second) {     if (u > v) swap(u, v);     G[u].push_back(pair<int, int>(v, second));     if (u > 1) G[v].push_back(pair<int, int>(u, second));   }   int n, m;   vector<int> op[N];   int Sum(int x, int y) {     if (x != -1 && y != -1) return sum[x][y];     return -1;   }   bool sp(int v) { return op[v].size(); }   vector<pair<int, int> > ext[N];   int root;   int xorsum[N];   int rtw[N];   bool used[N];   void dfs(int v, int p = -1) {     used[v] = true;     for (auto &e : G[v]) {       int u = e.first;       if (u == p) continue;       if (sp(v) && sp(u)) {         if (v < u) ext[v].push_back(e);         continue;       }       if (used[u]) {         if (v < u) {           op[root].back() =               Sum(op[root].back(), basic[e.second ^ xorsum[v] ^ xorsum[u]]);         }         continue;       }       xorsum[u] = xorsum[v] ^ e.second;       dfs(u, v);     }   }   int dp[2][400];   int main() {     build();     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v, second;       scanf( %d%d%d , &u, &v, &second);       add_edge(u, v, second);     }     for (auto &e : G[1]) {       int v = e.first;       op[v].push_back(0), op[v].push_back(0);     }     for (auto &e : G[1]) {       int v = e.first;       rtw[v] = e.second;       root = v;       dfs(v);     }     for (auto &se : G[1]) {       int v = se.first;       for (auto &e : ext[v]) {         int u = e.first, second = e.second;         assert(sp(v) && sp(u));         int op1 = op[u].back(), op2 = op[v].back();         op[v].clear();         op[u].clear();         op[v] = {0, Sum(op1, op2), Sum(op1, op2),                  Sum(Sum(op1, op2), basic[second ^ rtw[v] ^ rtw[u]])};       }     }     int now = 0;     dp[now][0] = 1;     for (auto &e : G[1]) {       int v = e.first;       if (!sp(v)) continue;       memset(dp[now ^ 1], 0, sizeof dp[now ^ 1]);       for (auto x : op[v]) {         if (x == -1) continue;         for (int i = 0; i < tot; i++) {           int j = Sum(i, x);           if (j != -1) add(dp[now ^ 1][j], dp[now][i]);         }       }       now ^= 1;     }     int ans = 0;     for (int i = 0; i < tot; i++) add(ans, dp[now][i]);     printf( %d n , ans);   }