主要是学习到了将一个区间加常数 or加x or加 x的2次方
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <cmath>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;
#define IOS ios::sync_with_stdio(false);
#define lowbit(x) ((x)&(-x))
int a[MAXN];
int b[MAXN];
int c[MAXN];
const int mod = 1e9 + 7;
inline void calc(int *s, int n) {
for (int i = 1; i <= n; i++) {
s[i] = (s[i] + s[i - 1]) % mod;
}
}
inline void solve() {
int n, q;
int ty, pos;
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
scanf("%d %d", &n, &q);
for (int i = 1; i <= q; i++) {
scanf("%d %d", &ty, &pos);
if (ty == 1) {
a[pos]++;
} else if (ty == 2) {
b[pos]++;
} else {
c[pos]++;
c[pos + 1]++;
}
}
calc(a, n);
for (int i = 1; i <= 2; i++)
calc(b, n);
for (int i = 1; i <= 3; i++)
calc(c, n);
for (int i = 1; i <= n; i++)
printf(i == n ? "%d\n" : "%d ", (a[i] + b[i] + c[i]) % mod);
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
solve();
}
return 0;
}