#include <bits/stdc++.h>
#include <cstring>
#include <sstream>
#define ll long long int
#define pb() push_back()
#define f(i,n) for(i=0;i<n;i++)
#define cin(n) scanf("%lld",&n)
#define cout(n) printf("%lld",n)
using namespace std;
ll prime(ll n)
{
ll i;
if(n==2)
return 1;
else if(n%2==0)
return 0;
else{
for(i=3;i*i<=n;i+=2){
if(n%i==0)
return 0;
}
}
return 1;
}
ll fun(ll n)
{
ll x=0;
while(n){
x+=n%10;
n=n/10;
}
return x;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,a,b,c,d,i,j,k,l,n,m,x,y,z;
cin>>t;
while(t--){
cin>>n>>k;
ll s[n+5];
map<ll,ll>h;
for(i=1;i<=n;i++)
cin>>s[i];
while(k--){
cin>>a;
if(a==1){
cin>>b>>c;
y=0;
for(j=b;j<=c;j++){
if(h[j]<11)
h[j]++;
else{
y=j;
break;
}
}
if(y){
for(i=c;i>y;i--){
if(h[i]<11)
h[i]++;
else
break;
}
}
}
else{
cin>>z;
d=h[z];
l=s[z];
while(d--){
l=fun(l);
}
cout<<l<<endl;
}
}
}
}
1205A - Almost Equal | 1020B - Badge |
1353A - Most Unstable Array | 770A - New Password |
1646B - Quality vs Quantity | 80A - Panoramix's Prediction |
1354B - Ternary String | 122B - Lucky Substring |
266B - Queue at the School | 1490A - Dense Array |
1650B - DIV + MOD | 1549B - Gregor and the Pawn Game |
553A - Kyoya and Colored Balls | 1364A - XXXXX |
1499B - Binary Removals | 1569C - Jury Meeting |
108A - Palindromic Times | 46A - Ball Game |
114A - Cifera | 776A - A Serial Killer |
25B - Phone numbers | 1633C - Kill the Monster |
1611A - Make Even | 1030B - Vasya and Cornfield |
1631A - Min Max Swap | 1296B - Food Buying |
133A - HQ9+ | 1650D - Twist the Permutation |
1209A - Paint the Numbers | 1234A - Equalize Prices Again |