#### PROB5: SHEET

See if a spreadsheet has a consistent formulation.

#### DESCRIPTION

Any given cell of a spreadsheet can have a formula that depends
on the value from some other cell. Before trying to calculate the
value of a cell it is important to determine if the definition of
the formula for that cell is circular.

Our spreadsheet only has a limited formulation for expressions:

`
definition := cell "=" expression
expression := term | expression "+" term | expression " " term
term := factor | term "*" factor | term "/" factor
factor := number | cell | "(" expression ")"
number := digit | number digit
digit := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
cell := "R" digit digit "C" digit digit
`

Valid cell rows and columns are 1 through 20, so that a total of 400
cells are available in our spreadsheet.
####
INPUT: `prob5.dat`

The input file will contain one or more lines, each
representing cells that are defined in the spreadsheet.

An example input file would be

` column 111111111122222222223
123456789012345678901234567890
line 1:R01C01=1[EOL]
2:R01C02=2[EOL]
3:R01C03=R01C01+R01C02[EOL]
4:R02C01=(R03C02+1)*R01C03[EOL]
5:R03C02=R02C01[EOL]
:[EOF]
`

Note that, if a an expression in some cell refers to some other
cell, the contents of that other cell will always be defined.
####
OUTPUT: `prob5.out`

Other than the standard header and trailer messages, a single
line is printed for each cell defined in the input file (and in the
same order). This should be the cell name followed by "circular" if
evaluating the cell results in a circular definition (either
directly or indirectly). If the cell can be evaluated without a
circular definition, then the word "ok" should follow the cell.

The correct output corresponding to the example input file would
be:

` column 111111111122222222223
123456789012345678901234567890
line 1:Program 5 by team 0[EOL]
2:R01C01 ok[EOL]
3:R01C02 ok[EOL]
4:R01C03 ok[EOL]
5:R02C01 circular[EOL]
6:R03C02 circular[EOL]
7:End of program 5 by team 0[EOL]
:[EOF]
`