//#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n; int tree[200][200][200]; int a[33000]; void inc(int x, int y, int z, int d) { for (int i = x; i < n; i = i | (i + 1)) for (int j = y; j < n; j = j | (j + 1)) for (int k = z; k < n; k = k | (k + 1)) tree[i][j][k] += d; } int sum(int x, int y, int z) { int s = 0; for (int i = x; i >= 0; i = (i&(i + 1)) - 1) for (int j = y; j >= 0; j = (j&(j + 1)) - 1) for (int k = z; k >= 0; k = (k&(k + 1)) - 1) s += tree[i][j][k]; return s; } int sum(int x1, int y1, int z1, int x2, int y2, int z2) { int s = sum(x2, y2, z2) - sum(x2, y2, z1 - 1) - sum(x2, y1 - 1, z2) - sum(x1 - 1, y2, z2) +sum(x1 - 1, y1 - 1, z2) + sum(x1 - 1, y2, z1 - 1) + sum(x2, y1 - 1, z1 - 1) - sum(x1 - 1, y1 - 1, z1 - 1); return s; } int main() { ios_base::sync_with_stdio(0); //freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout); // freopen("slalom.in", "r", stdin);freopen("slalom.out", "w", stdout); //Фенвик ВСЕ ДЕЛО В ЕДИНИЦАХ!!!! cin >> n; int t, x1, y1, z1, x2, y2, z2, d; while (1) { cin >> t; if (t == 3) break; if (t == 1) { cin >> x1 >> y1 >> z1 >> d; inc(x1, y1, z1, d); } else { cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; cout << sum(x1, y1, z1, x2, y2, z2) << endl; } } return 0; }