#000430

TheBroj

You are given the n-digit number. You have to perform m operations on it (some of them changing the number). There are three kinds of operations:


1 x - delete digit at position x in the current number (the rest of digits are then merging, and we get a new number that has one digit less)
2 x y - swap digits at positions x and y in the current number
3 - write the value of the current number modulo 10.007

Numbers x and y in operations 1 and 2 will always be less than or equal to the number of digits in current number. It is possible that in some moment we get a number with leading zeroes. Your task is to simulate these operations.


This is an interactive task, meaning that you should immediately write your answer after each operation of type 3. Only after your program writes the result for that operation (whether it is correct or not) you will be able to read next operation.


Also, make sure you ALWAYS flush the output before waiting for feedback. After writing the sequence, use:


cout.flush() in c++
fflush(stdout) in c
flush(output) in pascal

InputThe first line of standard input contains one positive integer number - starting number which has no more than 100.000 digits. The next line contains natural number m (1 <= m <= 50.000) - number of operations. The next m lines are operations in the above described format. Operations are executed in the order given in the input.


OutputFor each operation of type 3 you should write requested remainder value on standard output. Each value should be written on a separate line (note that the task is interactive).



Input:
10234
6
1 1
3
2 2 4
3
1 3
3

Output:
234
432
42



For given example, your program should run like this:
Read: 10234
Read: 6
Read: 1 1
Read: 3
Write: 234
Read: 2 2 4
Read: 3
Write: 432
Read: 1 3
Read: 3
Write: 42
Terminate

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.