All registers initially contain 000. The initial content of the RAM is read from standard input. The first instruction to be executed is at RAM address 0. All results are reduced modulo 1000.
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
The input to your program consists of up to 1000 3-digit unsigned integers, representing the contents of consecutive RAM locations starting at 0. Unspecified RAM locations are initialized to 000.
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
The output from your program is a single integer: the number of instructions executed up to and including the halt instruction. You may assume that the program does halt.
1 299 492 495 399 492 495 399 283 279 689 078 100 000 000 000
16