12715 - BigInt++   

Description

"int" is too small to store large numbers!

That's why you decided to implement your own data type, BigInt.

You need to implement 7 basic functions:

1. Constructor. It is initalized by a string representing a non-negative integer without leading zeroes (despite "0" itself).
2. Destructor.
3,4,5,6. ++x, x++, --x, x--, as in the C/C++ standard.
7: char* to_s(): returns a duplicate of the number in char*, e.g., "123".

 

 

UPDATE:

Note that you don't need to implement negative numbers. When the number is 0 and you have to decrement it, you can ignore the operation.

 

Input

The first line contains an integer T, representing the number of testcases that follow.

For each testcase, a non-negative integer less than pow(10, 1023) is given in the first line.

An integer Q follows, representing the number of operations regarding the testcase.

Q lines follow, each in the form of "B++", "++B", "B--", or "--B", the effect of which is the same as specified in the C/C++ standard.

Output

For each operation, print the result in one line, without leading zeroes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12715.cpp

Partial Judge Header

12715.h

Tags




Discuss