#ifndef LOCAL
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <climits>
#include <unordered_map>
#include <random>
#include <chrono>
#include <numeric>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <string>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <list>
#include <forward_list>
#include <set>
#include <unordered_set>
#include <cstdint>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
#pragma GCC target("avx,avx2,fma")
#endif
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) begin(x), end(x)
#ifdef LOCAL
#define isz(x) ((int)size(x))
#else
int isz(const auto& x) {
return x.size();
}
#endif
#define X first
#define Y second
int f(const vector<int>& a, int s, int p) {
int res = 0;
int x = (1 << p);
for (int i = s; i < isz(a); ++i) {
if (!(x & a[i])) {
x |= a[i];
res += i + 1;
}
}
return res;
}
void solve() {
int n, b;
cin >> n >> b;
vector<int> a(n);
for (auto& it : a) cin >> it;
for (int i = 0; i < n; ++i) {
int ans = 0;
for (int j = 0; j < b; ++j) {
ans += f(a, i, j);
cout << f(a,i,j) << ' ';
}
cout << ans << '\n';
}
cout << '\n';
}
signed main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// freopen("in.txt", "w", stdout); /* для стресс-ввода */
#endif
// cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t --> 0) {
solve();
}
}
I2lmbmRlZiBMT0NBTAogICNwcmFnbWEgR0NDIG9wdGltaXplKCJPZmFzdCx1bnJvbGwtbG9vcHMiKQojZW5kaWYKI2luY2x1ZGUgPGNsaW1pdHM+CiNpbmNsdWRlIDx1bm9yZGVyZWRfbWFwPgojaW5jbHVkZSA8cmFuZG9tPgojaW5jbHVkZSA8Y2hyb25vPgojaW5jbHVkZSA8bnVtZXJpYz4KI2luY2x1ZGU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