#include<algorithm>
#include<stdio.h>
using namespace std;
#define lson r<<1
#define rson r<<1|1
const int MAXN = 1e5+5;
struct stgmentTree
{//sum花瓶的剩余量
int x, y, sum, cover;//cover, 操作1赋值为释放花瓶,操作2沾满花瓶
int mid(){return (x+y)>>1;}
int len(){return y-x+1;}
}a[MAXN<<2];
int ans;
void Build(int r, int x, int y)
{
a[r].x = x, a[r].y = y;
a[r].sum = a[r].len(), a[r].cover = 0;
if(x == y)
return ;
Build(lson, x, a[r].mid());
Build(rson, a[r].mid()+1, y);
}
void Down(int r)
{
if(a[r].x != a[r].y && a[r].cover)
{
a[lson].cover = a[rson].cover = a[r].cover;
a[lson].sum = a[r].cover==2 ? 0 : a[lson].len();
a[rson].sum = a[r].cover==2 ? 0 : a[rson].len();
a[r].cover = 0;
}
}
void Insert(int r, int x, int y, int op)
{
if(a[r].x == x && a[r].y == y)
{
ans += a[r].len()-a[r].sum;
a[r].cover = op;
a[r].sum = (op==2 ? 0 : a[r].len());
return ;
}
Down(r);
if(y <= a[r].mid())
Insert(lson, x, y, op);
else if(x > a[r].mid())
Insert(rson, x, y, op);
else
{
Insert(lson, x, a[r].mid(), op);
Insert(rson, a[r].mid()+1, y, op);
}
a[r].sum = a[rson].sum + a[lson].sum;
}
int QueryPreSum(int r, int k)//求k前面的空花瓶数
{
Down(r);
if(a[r].x == a[r].y)
return 0;
if(k <= a[r].mid())
return QueryPreSum(lson, k);
else
return a[lson].sum + QueryPreSum(rson, k);
}
int QueryLast(int r, int p)//查找第p个花瓶位置
{
Down(r);
if(a[r].x == a[r].y)
return a[r].x;
if(a[lson].sum >= p)
return QueryLast(lson, p);
else
return QueryLast(rson, p-a[lson].sum);
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int N, M, op, x, y, L, R;
scanf("%d%d", &N, &M);
Build(1, 0, N-1);
while(M--)
{
scanf("%d%d%d", &op, &x, &y);
if(op == 1)
{
int PreSum = QueryPreSum(1, x);
if(PreSum == a[1].sum)
printf("Can not put any one.\n");
else
{
L = QueryLast(1, PreSum+1);
if(PreSum+y >= a[1].sum)
PreSum = a[1].sum;
else
PreSum += y;
R = QueryLast(1, PreSum);
Insert(1, L, R, 2);
printf("%d %d\n", L, R);
}
}
else
{
ans = 0;
Insert(1, x, y, 1);
printf("%d\n", ans);
}
}
printf("\n");
}
return 0;
}
/*
2
10 8
1 2 5
2 3 4
1 0 8
2 2 5
1 6 1
1 4 4
1 2 3