#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
ll ans = 0;
int f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
if(ch == '-')f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
ans = ans * 10 + ch - '0';
ch = getchar();
}
return ans * f;
}
const int maxn = 105;
struct sc{
int id, score;
bool operator < (const sc &s) const{
return s.score < score;
}
}s[maxn];
int sum[maxn];
string p[maxn];
int maxs;
int main(){
int n = read(), m = read();
for(int i = 0 ; i < m ; ++i)s[i].id = i, s[i].score = read();
for(int i = 1 ; i <= n ; ++i){
cin >> p[i];
for(int j = 0 ; j < m ; ++j)
if(p[i][j] == 'o')sum[i] += s[j].score;
sum[i] += i;
maxs = max(maxs, sum[i]);
}
sort(s, s + m);
for(int i = 1 ; i <= n ; ++i){
if(sum[i] == maxs){cout << 0 << endl;continue;}
int cnt = 0;
for(int j = 0 ; j < m ; ++j){
if(sum[i] > maxs){cout << cnt << endl;break;}
if(p[i][s[j].id] == 'x'){sum[i] += s[j].score;++cnt;}
}
}
return 0;
}