The code of the lock#1437

The code of the lock

1 second
64 megabytes
Very easy

Given a string composed of characters from '' to '', and an array of transformations called conversions. Each element in conversions follows the format "s_1-s_2", where s_1 and s_2 are strings of characters ''..''.

To obtain the resulting string from string , you must process each element of the conversions array in order, from the first to the last. For each element "s_1-s_2", perform the following actions:

Input

The first line contains the string . The second line contains the number , representing the number of elements in the conversions array. The subsequent lines list the elements of the conversions array.

The string consists of from to characters, each being ''..''. The conversions array contains from to elements. Each element in the conversions array is formatted as "s_1-s_2", where s_1 and s_2 are strings of to characters, each being ''..''.

Output

Output the string that represents the resulting code.

Examples

Example 1

Loading
Loading