Dadas maintains a balance sheet containing accounts. Each account has a type, a name, and a nonnegative amount. The three types are liabilities, equity, and assets.
A valid balance sheet satisfies
Each term is the sum of the amounts of all accounts of that type.
Some account amounts have been damaged and are represented by NULL. Dadas wants to remove all damaged accounts and replace them with one consolidated new account called OTHER, placed last in the output. Every undamaged account must retain its type, name, amount, and relative order.
The new account must be on the same side of the equality as the damaged accounts. If all damaged accounts are assets, the new account is an asset. Likewise, if all are liabilities or all are equity, the new account has that respective type. If damaged accounts appear on both sides, a unique restoration is impossible. If damaged accounts include both liabilities and equity, the new account's type is not uniquely determined, so restoration is also impossible.
If no account is damaged, do not add a new account, and preserve the original balance sheet. However, it must still satisfy the equality.
Every restored amount must be a nonnegative integer, and the result must be uniquely determined. Restore the balance sheet according to these rules.
The first line contains the number of accounts, .
Each of the following lines contains , , and , separated by spaces.
If the balance sheet cannot be restored, print impossible task!.
Otherwise, print the number of accounts in the restored balance sheet on the first line. Then print lines, each containing the account type, name, and amount, separated by spaces. The type is an integer , , or .
Print all undamaged accounts first, preserving their input order. If there are damaged accounts, print the new consolidated account OTHER last. If none is damaged, print no new account.
The total of the damaged assets is .
Damaged accounts occur on both sides of the equality, so there is no unique restoration.
The damaged liability amount is .
indicates the account type: for liabilities, for equity, and for assets. is the account name. is either a nonnegative integer amount or NULL; NULL means the amount has been damaged.
The input is given in the following format:
_).NULL or an integer satisfying ().The damaged asset would need an amount of , which is negative.