#define _USE_MATH_DEFINES
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

map<string, int> f(string s, int& i) {
	map<string, int> m;
	for (;;) {
		map<string, int> _m;
		if (s[i] == '(') {
			i++;
			_m = f(s, i);
		}
		else {
			string t;
			t.push_back(s[i]);
			i++;
			if ('a'<=s[i] && s[i]<='z') {
				t.push_back(s[i]);
				i++;
			}
			_m[t] = 1;
		}
		int z = 0;
		for (; '0'<=s[i] && s[i]<='9'; i++)
			z = z * 10 + (s[i] - '0');
		if (z == 0) z = 1;
		for (auto x: _m) m[x.first] += z * x.second;
		if (s[i] == ')') break;
	}
	i++;
	return m;
}

int main() {
	for (;;) {
		string s; cin >> s;
		if (s == ".") break;
		vector<map<string, int> > vm;
		int l = 0, sign = 1;
		for (;;) {
			int r;
			for (r = l; s[r] != '+' && s[r] != '-' && s[r] != '.'; r++);
			int i = 0;
			map<string, int> m = f(s.substr(l, r - l) + ")", i);
			for (auto& x: m) x.second *= sign;
			vm.push_back(m);
			if (s[r] == '+') l = r + 1;
			if (s[r] == '-') {
				l = r + 2;
				sign = -1;
			}
			if (s[r] == '.') break;
		}
		int M = vm.size();
		vector<string> v;
		for (auto m: vm)
			for (auto x: m)
				v.push_back(x.first);
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
		int N = v.size();
		vector<vector<ll> > a(N, vector<ll>(M));
		for (int j = 0; j < M; j++)
			for (auto x: vm[j]) {
				int i = lower_bound(v.begin(), v.end(), x.first) - v.begin();
				a[i][j] = x.second;
			}
		int i = 0;
		for (int j = 0; j < M; j++) {
			int k;
			for (k = i; k < N && a[k][j] == 0; k++);
			if (k == N) continue;
			swap(a[i], a[k]);
			for (int k = i + 1; k < N; k++) {
				ll d = gcd(a[i][j], a[k][j]);
				ll x = a[i][j] / d, y = a[k][j] / d;
				for (int _j = j; _j < M; _j++)
					a[k][_j] = x * a[k][_j] - y * a[i][_j];
				d = 0;
				for (int _j = j; _j < M; _j++)
					d = gcd(d, a[k][_j]);
				if (d == 0) continue;
				for (int _j = j; _j < M; _j++)
					a[k][_j] /= d;
			}
			i++;
		}
		vector<int> x(M);
		for (x[M - 1] = 1; ; x[M - 1]++) {
			bool ok = true;
			int i;
			for (i = M - 2; i >= 0; i--) {
				ll sum = 0;
				for (int j = M - 1; j > i; j--)
					sum += a[i][j] * x[j];
				if (sum % a[i][i]) break;
				x[i] = -sum / a[i][i];
				if (x[i] <= 0) break;
			}
			if (i == -1) break;
		}
		for (int j = 0; j < M; j++)
			cout << x[j] << (j + 1 < M ? ' ' : '\n');
	}
}