13414 - String Calculator   

Description

In this problem, you need to finish a string calculator.

The calculator has four string operators:

  • a + b: Concatenate the string b after the string a.
  • a - b: If string b has appeared in string a, delete the first appearance of b in a, otherwise output "error".
  • a / b: The number of occurrences of string b in string a.
  • a @ b1_b2_b3_...bk: For all strings bi concatenated with _, if has appeared in string bi, add bi to a list, output the list in this order:
    • ​If |x| > |y|: x is listed before y
    • If |x| = |y|: follows the dictionary order

Input

The first line contains an integer N

The following N lines, each line contains an operation.

testcase:

(2/12) 0 < N < 100, 0 < |a|, |b| <= 10, only "+" operation

(3/12) 0 < N < 100, 0 < |a|, |b| <= 10, only "-" operation

(3/12) 0 < N < 100, 0 < |a|, |b| <= 10, only "/" operation

(2/12) 0 < N < 100, 0 < |a|, |bi| <= 10, 0 < k <= 500 , only "@" operation

(2/12) 0 < N < 100, 0 < |a|, |bi| <= 10, 0 < k <= 10000 , only "@" operation

Output

The output contains N lines, output the calculated result.

Sample Input  Download

Sample Output  Download

Tags




Discuss