#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int pos;
string str;
map<string, int> idx;

int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a/gcd(a,b)*b; }

vector<int> getCof(){
	vector<int> res(idx.size(), 0);
	if(str[pos]=='+'||str[pos]=='-'||str[pos]=='.'||str[pos]==')') return res;
	if(str[pos]=='('){ pos++; res = getCof(); pos++; }
	else {
		string t;
		t += str[pos++];
		if(pos<str.size()&&islower(str[pos])) t += str[pos++];
		res[idx[t]]++;
	}
	int mul = 1;
	if(isdigit(str[pos])){
		mul = str[pos++]-'0';
		if(isdigit(str[pos])) mul = 10*mul + str[pos++]-'0';
	}
	vector<int> next = getCof();
	for(int i=0;i<res.size();i++) res[i] = res[i]*mul + next[i];
	return res;
}

int main(){
	while(cin >> str){
		if(str == ".") break;
		int size = 0;
		idx.clear();
		for(int i=0;i<str.size();i++){
			string t;
			if(isupper(str[i])){
				t += str[i];
				if(i+1<str.size()&&islower(str[i+1])) t += str[i+1];
				if(!idx.count(t)){ idx[t] = size++; }
			}
		}
		pos = 0;
		bool rev = false;
		vector< vector<int> > v(size);
		while(str[pos]!='.'){
			if(str[pos]=='+') pos++;
			if(str[pos]=='-') { rev = true; pos += 2; }
			vector<int> cof = getCof();
			for(int i=0;i<size;i++)
				v[i].push_back(!rev ? cof[i] : -cof[i]);
		}
		for(int i=0;i<v[0].size()-1;i++){
			if(v[i][i]==0){
				int idx = i;
				while(!v[idx][i]) idx++;
				swap(v[i], v[idx]);
			}
			for(int j=0;j<size;j++){
				if(j == i) continue;
				if(v[j][i]==0) continue;
				int mulA = v[j][i]/gcd(v[i][i],v[j][i]);
				int mulB = v[i][i]/gcd(v[i][i],v[j][i]);
				for(int k=0;k<v[j].size();k++) v[j][k] = v[j][k]*mulB-v[i][k]*mulA;
			}
			for(int j=0;j<size;j++){
				int div = 0;
				for(int k=0;k<v[j].size();k++)
					if(v[j][k]!=0) div = !div ? abs(v[j][k]) : gcd(div, abs(v[j][k]));
				if(div!=0)
					for(int k=0;k<v[j].size();k++) v[j][k] /= div;
			}
		}
		long long mul = 1;
		for(int i=0;i<v[0].size()-1;i++) mul = lcm(mul, abs(v[i][i]));
		for(int i=0;i<v[0].size()-1;i++) cout << mul/abs(v[i][i])*abs(v[i].back()) << " ";
		cout << mul << endl;
	}
}