Informações

Prazo de entrega Sem prazo
Limite de submissão No limitation

Entrar

Contest 1 2019 - A


List programmig

The List programming language is a language for working with lists of integers. The language has two built-in functions: R (reverse) and D (drop). The function R reverses its input list, and D drops the first element of its input and returns the rest, or gives an error in case its input is an empty list.

To get more advanced behavior, functions can be composed: AB is the function that first applies A to its input and then B to the resulting list. For example, RDD is a function that reverses a list and thendrops the first two elements.

Given a List program and its input, return its output or error in case D is applied to an empty list.

Input

The first line contains a string \(P\) over the alphabet "RD" representing a List program.

The second line contains a string representation of the input list.

Lists are represented as the character [ followed by a comma-separated list of integers followed by the character ]. There are no spaces in the list representation.

Constraints

  • \(1 \leq |P| \leq 10^5\)
  • The number of elements in the input list is at most \(10^5\). The input list can be empty.

Output

A single line with the resulting list or error if there was an error.

The output format of the list needs to be the same as the input format, that is, the character [ followed by a comma-separated list of integers followed by the character ]. There are no spaces in the list representation.

Sample Test Cases

Sample input 1

Sample output 1

Sample input 2

Sample output 2

Sample input 3

Sample output 3


Max file size: 1.0 MiB
Allowed extensions: .java, .cpp, .py