#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
const int maxn = 2e5+10;
int a[maxn];
struct line {
int l,r;
line(int a=0,int b=0):l(a),r(b){}
bool operator < (const line & rhs) const {
return l < rhs.l;
}
}lines[maxn];
int main()
{
int t,n,m;
scanf ("%d",&t);
int cal = 0;
while(t--) {
scanf ("%d%d",&n,&m);
memset(a,0,sizeof(a));
int aa,b,cnt = 0;
for (int i = 1; i <= m; i++) {
scanf ("%d%d",&aa,&b);
lines[cnt].l = aa, lines[cnt].r = b, cnt++;
}
sort(lines,lines+cnt);
int last = 0,cur = 0;
bool first = true;
set<int> s;
for (int i = 0; i < cnt; i++) {
int x = lines[i].l;
if (first) last = x,cur = x, first = false;
for (int j = x-1; j >= last; j--) s.erase(a[j]);
last = x;
int res = 1;
cur = max(x,cur);
for (int j = cur; j <= lines[i].r; j++) if (!a[j]) {
while(res <= n) {
if (s.count(res)) { res++; continue; }
else { a[j] = res, s.insert(res); res++; break; }
}
}
cur = max(cur,lines[i].r+1);
}
for (int i = 1; i <= n; i++) if (!a[i]) a[i] = 1;
for (int i = 1; i <= n; i++) {
else cout << a[i] << " ";
}
}
return 0;
}