#include "stdio.h"
#include "string.h"
#include "queue"
#include "vector"
#include "algorithm"
using namespace std;
const int maxn = 50005;
const int mod = 10007;
const int inf = 1<<30;
int n,m;
int op,x,y,fir,las,f;
struct node
{
int c;
}tree[maxn<<2];
int Pow( int a,int x )
{
int ans = 1;
for( int i = 1; i <= x; i ++ )
{
ans = ( ans*a )%mod;
}
return ans;
}
void PushUp( int rt )
{
if( tree[rt<<1].c == tree[rt<<1|1].c && tree[rt<<1].c != -1 )
tree[rt].c = tree[rt<<1].c;
}
void PushDown( int rt )
{
if( tree[rt].c != -1 )
{
tree[rt<<1].c = tree[rt<<1|1].c = tree[rt].c;
tree[rt].c = -1;
}
}
void BuildTree( int rt,int ld,int rd )
{
tree[rt].c = 0;
if( ld < rd )
{
int mid = ( ld+rd )>>1;
BuildTree( rt<<1,ld,mid );
BuildTree( rt<<1|1,mid+1,rd );
}
}
void updata( int rt,int ld,int rd )
{
if( f <= 0 ) return;
if( x <= ld && rd <= y && tree[rt].c != -1 && f >= ( rd - ld + 1 ) )
{
if( tree[rt].c == 0 ){
tree[rt].c = 1;
if( fir == -1 ) fir = ld;
las = rd;
f -= rd - ld + 1;
}
return;
}
PushDown( rt );
int mid = ( ld+rd )>>1;
if( x <= mid ) updata( rt<<1,ld,mid );
if( y > mid ) updata( rt<<1|1,mid+1,rd );
PushUp( rt );
}
int query( int rt,int ld,int rd )
{
if( x <= ld && rd <= y && tree[rt].c != -1 )
{
if( tree[rt].c == 1 ){
tree[rt].c = 0;
return rd - ld + 1;
}
else
return 0;
}
if( y < ld || x > rd ) return 0;
PushDown( rt );
int mid = ( ld+rd )>>1;
int l = query( rt<<1,ld,mid );
int r = query( rt<<1|1,mid+1,rd );
PushUp( rt );
return l + r;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
int cas;
scanf("%d",&cas);
while( cas -- )
{
scanf("%d%d",&n,&m);
BuildTree( 1,0,n-1 );
for( int i = 0; i < m; i ++ )
{
scanf("%d",&op);
if( op == 1 )
{
scanf("%d%d",&x,&f);
fir = las = -1;
y = n-1;
updata( 1,0,n-1 );
if( fir == -1 )
puts("Can not put any one.");
else
printf("%d %d\n",fir,las);
}
else{
scanf("%d%d",&x,&y);
printf("%d\n",query( 1,0,n-1 ));
}
}
puts("");
}
return 0;
}