#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 build(ll arr[] , ll node , ll left , ll right)
{
if(left == right)
{
tree[node] = arr[left];
return ;
}
ll mid = (left + right) >> 1 ;
build(arr,2*node , left , mid);
build(arr,2*node+1,mid+1,right);
tree[node] = tree[2*node] + tree[2*node+1];
}
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 ;
cin>>t ;
ll cnt = 0;
while(t--)
{
ll n , q ;
cin>>n>>q ;
ll arr[100005] = {0};
build(arr,1,0,n-1);
cout<<"Scenario #"<<++cnt<<":\n";
while(q--)
{
string s; ;
ll x ,y ;
cin>>s>>x>>y;
if(x > y)
cout<<"0\n";
else if(s[0] == 'a')
cout<<query(1,0,n-1,x-1,y-1)<<"\n";
else
{
update(1,0,n-1,x-1,y-1,1);
cout<<"OK\n";
}
}
}
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+C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SB0bykKICAgIHsKICAgICAgICB0cmVlW25vZGVdICs9IChyaWdodC1sZWZ0KzEpKnZhbDsKCiAgICAgICAgaWYobGVmdCAhPSByaWdodCkKICAgICAgICB7CiAgICAgICAgICAgIGxhenlbMipub2RlXSArPSB2YWwgOwogICAgICAgICAgICBsYXp5WzIqbm9kZSsxXSArPSB2YWwgOwogICAgICAgIH0KICAgICAgICByZXR1cm4gOwogICAgfQogICAgbGwgbWlkID0gKGxlZnQgKyByaWdodCkgPj4gMSA7CiAgICB1cGRhdGUobm9kZSoyICwgbGVmdCAsIG1pZCAsIGZyb20gLCB0byAsIHZhbCk7CiAgICB1cGRhdGUoMipub2RlKzEsbWlkKzEscmlnaHQsZnJvbSx0byx2YWwpOwogICAgdHJlZVtub2RlXSA9IHRyZWVbMipub2RlXSArIHRyZWVbMipub2RlKzFdOwp9CgpsbCBxdWVyeShsbCBub2RlICwgbGwgbGVmdCwgbGwgcmlnaHQsIGxsIGZyb20sIGxsIHRvKQp7CiAgICBpZihsYXp5W25vZGVdICE9IDApCiAgICB7CiAgICAgICAgdHJlZVtub2RlXSArPSAocmlnaHQgLSBsZWZ0ICsgMSkgKiBsYXp5W25vZGVdOwogICAgICAgIGlmKGxlZnQgIT0gcmlnaHQpCiAgICAgICAgewogICAgICAgICAgICBsYXp5WzIqbm9kZV0gKz0gbGF6eVtub2RlXTsKICAgICAgICAgICAgbGF6eVsyKm5vZGUrMV0gKz0gbGF6eVtub2RlXTsKICAgICAgICB9CiAgICAgICAgbGF6eVtub2RlXSA9IDAgOwogICAgfQogICAgaWYobGVmdCA+IHJpZ2h0IHx8IGxlZnQgPiB0byB8fCByaWdodCA8IGZyb20pCiAgICAgICAgcmV0dXJuIDAgOwoKICAgIGlmKGxlZnQgPj0gZnJvbSAmJiByaWdodCA8PSB0bykKICAgICAgICByZXR1cm4gdHJlZVtub2RlXTsKCiAgICBsbCBtaWQgPSAobGVmdCArIHJpZ2h0KSA+PiAxIDsKICAgIHJldHVybiBxdWVyeSgyKm5vZGUgLCBsZWZ0ICwgbWlkICwgZnJvbSAsIHRvKSArCiAgICAgICAgICAgcXVlcnkoMipub2RlKzEsbWlkKzEscmlnaHQsZnJvbSx0byk7Cn0KCmludCBtYWluKCkKewogICAgbGwgdCA7CiAgICBjaW4+PnQgOwogICAgbGwgY250ID0gMDsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBsbCBuICwgcSA7CiAgICAgICAgY2luPj5uPj5xIDsKICAgICAgICBsbCBhcnJbMTAwMDA1XSA9IHswfTsKICAgICAgICBidWlsZChhcnIsMSwwLG4tMSk7CiAgICAgICAgY291dDw8IlNjZW5hcmlvICMiPDwrK2NudDw8IjpcbiI7CiAgICAgICAgd2hpbGUocS0tKQogICAgICAgIHsKICAgICAgICAgICAgc3RyaW5nIHM7IDsKICAgICAgICAgICAgbGwgeCAseSA7CiAgICAgICAgICAgIGNpbj4+cz4+eD4+eTsKICAgICAgICAgICAgaWYoeCA+IHkpCiAgICAgICAgICAgICAgICBjb3V0PDwiMFxuIjsKICAgICAgICAgICAgZWxzZSBpZihzWzBdID09ICdhJykKICAgICAgICAgICAgICAgY291dDw8cXVlcnkoMSwwLG4tMSx4LTEseS0xKTw8IlxuIjsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB1cGRhdGUoMSwwLG4tMSx4LTEseS0xLDEpOwogICAgICAgICAgICAgICAgY291dDw8Ik9LXG4iOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgIHJldHVybiAwIDsKfQo=