#C9408. Decode String

    ID: 53498 Type: Default 1000ms 256MiB

Decode String

Decode String

You are given an encoded string s. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is repeated exactly k times. Note that k is a positive integer and there are no extra white spaces in the string. You may assume that the input string is always valid; No extra white spaces, and the square brackets are well-formed.

For example:

  • Input: 3[a]2[bc] → Output: aaabcbc
  • Input: 3[a2[c]] → Output: accaccacc
  • Input: 2[abc]3[cd]ef → Output: abcabccdcdcdef

Your task is to decode the given string and output its decoded form.

inputFormat

The input consists of a single line containing the encoded string s.

Constraints:

  • The string consists of digits, letters, and square brackets.
  • 1 ≤ Length of s ≤ 1000

outputFormat

Output a single line containing the decoded string.

## sample
3[a]2[bc]
aaabcbc