Stupid BrotherK!
2 2
#include <iostream>
#include<cstring>
using namespace std;
long long v[1005],a[1005][3];
long long mm(long long m,long long n)
{
long long a,b,c;
if( n > m) {
a = n ;
b = m ;
}
else {
a = m ; b = n;
}
while ( b != 0 ) { /* 最小公倍数 = m*n/GCD(m,n) */
c = a % b ;
a = b ;
b = c ;
}
return a ;
}
long long ma(long long m,long long n){
if(m==0)return n;
else
return (m*n)/mm(m,n);
}
long long gcd(long long x,long long y){
long long l=v[x];
for(int i=x+1;i<=y;i++)
l=mm(l,v[i]);
return l;
}
int main(){
int t;
cin>>t;
int n,m;
long long x,y,z;
while(t--)
{bool p=1;
memset(v,0,sizeof(v));
memset(a,0,sizeof(a));
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>x>>y>>z;
a[i][0]=x;a[i][1]=y;
a[i][2]=z;
for(int k=x;k<=y;k++){
v[k]=ma(v[k],z);
}
}
int i;
for(int i=0;i<m;i++)
if(gcd(a[i][0],a[i][1])!=a[i][2]){
p=0;break;
}
if(p==0)cout<<"Stupid BrotherK!";
else
{
if(v[1]==0)cout<<1;
else cout<<v[1];
for(int i=2;i<=n;i++)
if(v[i]==0)cout<<" "<<1;
else cout<<" "<<v[i];
}
cout<<endl;
}
return 0;}