#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long LL;

class SubrectanglesOfTable
{
public:
	vector<long long> getQuantity(vector <string> table) 
	{
		for(int i=0,n=table.size(); i<n; ++i)
			table.push_back( table[i]+=table[i] );

		vector<LL> ans(26);

		LL Y = table.size(), X = table[0].size();
		for(LL y=0; y<Y; ++y)
			for(LL x=0; x<X; ++x)
				ans[table[y][x]-'A'] += (y+1)*(x+1)*(Y-y)*(X-x);
		return ans;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time;string timer() { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }

template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
int verify_case(const vector<long long> &Expected, const vector<long long> &Received) { if (Expected == Received) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } return 0;}

template<int N> struct Case_ { Case_(){start_time=clock();} };
char Test_(...);
int Test_(Case_<0>) {
	string table_[] = {"OK"};
	  vector <string> table(table_, table_+sizeof(table_)/sizeof(*table_)); 
	long RetVal_[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	  vector<long long> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SubrectanglesOfTable().getQuantity(table)); }
int Test_(Case_<1>) {
	string table_[] = {"GOOD", "LUCK"};
	  vector <string> table(table_, table_+sizeof(table_)/sizeof(*table_)); 
	long RetVal_[] = {0, 0, 320, 280, 0, 0, 280, 0, 0, 0, 280, 280, 0, 0, 640, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0 };
	  vector<long long> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SubrectanglesOfTable().getQuantity(table)); }
int Test_(Case_<2>) {
	string table_[] = {"TANYA",
 "HAPPY",
 "BIRTH",
 "DAYYY"};
	  vector <string> table(table_, table_+sizeof(table_)/sizeof(*table_)); 
	long RetVal_[] = {5168, 1280, 0, 1120, 0, 0, 0, 2560, 1472, 0, 0, 0, 0, 1344, 0, 3008, 0, 1536, 0, 2592, 0, 0, 0, 0, 6320, 0 };
	  vector<long long> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_)); 
	return verify_case(RetVal, SubrectanglesOfTable().getQuantity(table)); }

template<int N> void Run_() { cerr << "Test Case #" << N << "..." << flush; Test_(Case_<N>()); Run_<sizeof(Test_(Case_<N+1>()))==1 ? -1 : N+1>(); }
template<>      void Run_<-1>() {}
int main() { Run_<0>(); }
// END CUT HERE

