Spreadsheet

No attempts yetTime limit1sMemory limit128 MB

Problem

A spreadsheet is made up of many "cells" arranged in a rectangular grid. Each cell is addressed by one letter from $A$ to $J$ (the row) and one digit from $1$ to $9$ (the column). Thus the top-left cell is $A1$ and the bottom-right cell is $J9$.

Every cell has a value, which is given in one of two ways:

  1. an integer from $0$ to $1000$;
  2. the sum of the values of up to $10$ other cells.

Cell values may depend on one another (for instance, $A1$'s sum may depend on $B6$, which in turn depends on $C9$). However, a cell whose value depends on itself, directly or indirectly, is undefined (for example, $A1$ depending on $G8$ which depends on $A1$). A cell that depends on an undefined cell is itself undefined as well. Given the specification of every cell in the spreadsheet, compute and output the value of each cell.

Input

The input consists of $10$ lines, one per spreadsheet row. Each line contains $9$ cell descriptions. Each description is either an integer between $0$ and $1,000$, or the sum of $1$ to $10$ distinct cell names joined by a + symbol (e.g. A1+B5+D3).

Output

Print $10$ lines with $9$ numbers per line, giving the value of every cell in the spreadsheet. If a cell is undefined, print an asterisk (*) instead of its value. No cell's final value exceeds $1,000,000,000$.