#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MAX = 100009 ;
ll tree[5*MAX] = {0};
ll lazy[5*MAX] = {0};
void update(ll node , ll left , ll right , ll from , ll to , ll val)
{
if(lazy[node] != 0)
{
tree[node] += (right-left+1) * lazy[node];
if (left != right)
{
lazy[2*node] += lazy[node];
lazy[2*node+1] += lazy[node];
}
lazy[node] = 0;
}
if (left > right || left > to || right < from)
return ;
if(left >= from && right <= to)
{
tree[node] += (right-left+1)*val;
if(left != right)
{
lazy[2*node] += val ;
lazy[2*node+1] += val ;
}
return ;
}
ll mid = (left + right) >> 1 ;
update(node*2 , left , mid , from , to , val);
update(2*node+1,mid+1,right,from,to,val);
tree[node] = tree[2*node] + tree[2*node+1];
}
ll query(ll node , ll left, ll right, ll from, ll to)
{
if(lazy[node] != 0)
{
tree[node] += (right - left + 1) * lazy[node];
if(left != right)
{
lazy[2*node] += lazy[node];
lazy[2*node+1] += lazy[node];
}
lazy[node] = 0 ;
}
if(left > right || left > to || right < from)
return 0 ;
if(left >= from && right <= to)
return tree[node];
ll mid = (left + right) >> 1 ;
return query(2*node , left , mid , from , to) +
query(2*node+1,mid+1,right,from,to);
}
int main()
{
ll t ;
scanf("%lld" , &t);
ll cnt = 0;
while(t--)
{
for(int i = 0 ; i < 5*MAX ; ++i)
lazy[i] = tree[i] = 0 ;
ll n , q ;
scanf("%lld %lld" , &n , &q);
ll arr[100005] = {0};
printf("Scenario #%lld:\n",++cnt);
while(q--)
{
char s[15];
ll x ,y ;
scanf("%s",&s);
scanf("%lld %lld" , &x , &y);
if(x > y)
printf("0\n");
else if(s[0] == 'a')
printf("%lld\n",query(1,0,n-1,x-1,y-1));
else
{
update(1,0,n-1,x-1,y-1,1);
printf("OK\n");
}
}
}
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGwgOwoKCmNvbnN0IGxsIE1B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SsxXTsKfQoKbGwgcXVlcnkobGwgbm9kZSAsIGxsIGxlZnQsIGxsIHJpZ2h0LCBsbCBmcm9tLCBsbCB0bykKewogICAgaWYobGF6eVtub2RlXSAhPSAwKQogICAgewogICAgICAgIHRyZWVbbm9kZV0gKz0gKHJpZ2h0IC0gbGVmdCArIDEpICogbGF6eVtub2RlXTsKICAgICAgICBpZihsZWZ0ICE9IHJpZ2h0KQogICAgICAgIHsKICAgICAgICAgICAgbGF6eVsyKm5vZGVdICs9IGxhenlbbm9kZV07CiAgICAgICAgICAgIGxhenlbMipub2RlKzFdICs9IGxhenlbbm9kZV07CiAgICAgICAgfQogICAgICAgIGxhenlbbm9kZV0gPSAwIDsKICAgIH0KICAgIGlmKGxlZnQgPiByaWdodCB8fCBsZWZ0ID4gdG8gfHwgcmlnaHQgPCBmcm9tKQogICAgICAgIHJldHVybiAwIDsKCiAgICBpZihsZWZ0ID49IGZyb20gJiYgcmlnaHQgPD0gdG8pCiAgICAgICAgcmV0dXJuIHRyZWVbbm9kZV07CgogICAgbGwgbWlkID0gKGxlZnQgKyByaWdodCkgPj4gMSA7CiAgICByZXR1cm4gcXVlcnkoMipub2RlICwgbGVmdCAsIG1pZCAsIGZyb20gLCB0bykgKwogICAgICAgICAgIHF1ZXJ5KDIqbm9kZSsxLG1pZCsxLHJpZ2h0LGZyb20sdG8pOwp9CgppbnQgbWFpbigpCnsKICAgIGxsIHQgOwogICAgc2NhbmYoIiVsbGQiICwgJnQpOwogICAgbGwgY250ID0gMDsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBmb3IoaW50IGkgPSAwIDsgaSA8IDUqTUFYIDsgKytpKQogICAgICAgICAgICBsYXp5W2ldID0gdHJlZVtpXSA9IDAgOwogICAgICAgIGxsIG4gLCBxIDsKICAgICAgICBzY2FuZigiJWxsZCAlbGxkIiAsICZuICwgJnEpOwogICAgICAgIGxsIGFyclsxMDAwMDVdID0gezB9OwogICAgICAgIHByaW50ZigiU2NlbmFyaW8gIyVsbGQ6XG4iLCsrY250KTsKICAgICAgICB3aGlsZShxLS0pCiAgICAgICAgewogICAgICAgICAgICBjaGFyIHNbMTVdOwogICAgICAgICAgICBsbCB4ICx5IDsKICAgICAgICAgICAgc2NhbmYoIiVzIiwmcyk7CiAgICAgICAgICAgIHNjYW5mKCIlbGxkICVsbGQiICwgJnggLCAmeSk7CiAgICAgICAgICAgIGlmKHggPiB5KQogICAgICAgICAgICAgICBwcmludGYoIjBcbiIpOwogICAgICAgICAgICBlbHNlIGlmKHNbMF0gPT0gJ2EnKQogICAgICAgICAgICAgICBwcmludGYoIiVsbGRcbiIscXVlcnkoMSwwLG4tMSx4LTEseS0xKSk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdXBkYXRlKDEsMCxuLTEseC0xLHktMSwxKTsKICAgICAgICAgICAgICAgIHByaW50ZigiT0tcbiIpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgIHJldHVybiAwIDsKfQo=