11431 - String Operation   

Description

Given a set of strings, perform the operations according to the following commands.

 

Commands: (n will not be equal to m)

s n m:

Swap the nth string and the mth string.

i n m:

Insert the mth string at the tail of the nth string.

si n m:

Swap the specified strings first, and then insert.

is n m:

Insert first, and then swap the two specified strings.

t n m:

If the nth string is equal to the mth string, do i n m. Otherwise, do s n m.

e:

Exit.

 

Note:

You will be provided with main.cpp and function.h, and asked to implement function.cpp including

Str::Str(char*);

Str::Str(const Str &);

bool Str::operator==( const Str &) const;

 

 

Input

The first line is an integer N indicating the number of input strings.

The following N lines each contains one input string.

Starting from the N+2th line will be a sequence of commands.

Output

Output the final result of the input strings.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11431.cpp

Partial Judge Header

11431.h

Tags




Discuss