#include <bits/stdc++.h>
using LL = long long;
const int N = 100010;
int n, m;
int w[N];
struct Node {
int l, r;
LL sum, max, min;
} tr[N << 2];
void pushup(int u) {
tr[u].sum = tr[u << 1].sum + tr[u << 1 | 1].sum;
tr[u].max = std::max(tr[u << 1].max, tr[u << 1 | 1].max);
tr[u].min = std::min(tr[u << 1].min, tr[u << 1 | 1].min);
}
void build(int u, int l, int r) {
if (l == r) {
tr[u] = {l, r, w[r], w[r], w[r]};
if (w[r] == 0) {
tr[u].max = tr[u].min = 100;
}
} else {
tr[u] = {l, r};
int mid = l + r >> 1;
build(u << 1, l, mid);
build(u << 1 | 1, mid + 1, r);
pushup(u);
}
}
void modify(int u, int l, int r, int x, int y, int k) {
if (tr[u].max <= 100 && tr[u].min >= 99) return;
if (l > y || r < x) return;
if (l == r) {
while (k && tr[u].max != 99 && tr[u].max != 100) {
tr[u].max = std::sqrt(tr[u].max) * 10 + .5;
k--;
}
tr[u].sum = tr[u].min = tr[u].max;
} else {
int mid = l + r >> 1;
modify(u << 1, l, mid, x, y, k);
modify(u << 1 | 1, mid + 1, r, x, y, k);
pushup(u);
}
}
int main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
std::cin >> n >> m;
for (int i = 1; i <= n; i++) {
std::cin >> w[i];
}
build(1, 1, n);
int op;
while (m--) {
std::cin >> op;
if (op == 1) {
int l, r, k;
std::cin >> l >> r >> k;
modify(1, 1, n, l, r, k);
} else std::cout << tr[1].sum << "\n";
}
return 0;
}