#include<bits/stdc++.h> usingnamespace std; constlonglong mod = 1e9 + 7; longlongksm(longlong a, longlong x) { longlong ret = 1; while (x) { if (x & 1) ret = ret * a % mod; a = a * a % mod; x >>= 1; } return ret; } intmain() { int _, n, l, r, m; longlong x, t; scanf("%d", &_); while (_--) { scanf("%d%d", &n, &m); t = 0; while (m--) { scanf("%d%d%lld", &l, &r, &x); t |= x; } printf("%lld\n", t * ksm(2, n - 1) % mod); } return0; }