#include #include #include char str[65536]; long n; long a[16]; int main() { long d; long depth = 0; std::cin >> n >> d; scanf("%s", str); for(long i = 0; i <= n; ++i) { if( str[i] == '{' ) { depth += 1; continue; } if( str[i] == '}' ) { depth -= 1; continue; } if( str[i] == 'x' || ( '0' <= str[i] && str[i] <= '9' ) ) { long temp = 1; long red = 0; for(long j = i; j <= n; ++j) { if( '0' <= str[j] && str[j] <= '9' ) { temp = str[j] - '0'; red += 1; continue; } if( str[j] == '+' || str[j] == '}' || str[j] == '\0' ) { long d = (j-i+1)/2-red; for(long k = 0; k < depth; ++k) { temp *= d; d -= 1; } if( (j-i+1)/2-depth-red >= 0 ) { a[(j-i+1)/2-depth-red] += temp; } i = j-1; break; } } continue; } } for(long i = 0; i < d; ++i) { std::cout << a[i] << " "; } std::cout << a[d] << std::endl; return 0; }