
ZOJ Problem Set  3179
Abacus is a manual computing device consisting of a frame holding parallel rods strung with movable beads. How to calculate with Abacus:
Initially, all the upper beads are moved up and all the lower beads are moved down. This represents the number 0. When you add some number, you move upper beads down or move lower beads up. For example, when two lower beads in the first (from right) rod are moved up, it represents the number 2. When one upper bead in the first rod is moved down and three lower beads in the third rod are moved up, it represents 305. Now with the abacus, your teacher asks you to calculate the sum from number x to number y, both inclusive. After you finish the work, you want to check whether you make any mistake during the calculation. Input The first line of the input contains an integer T (T <= 50), indicating the number of cases. Each case has two parts. The first part in one line consists of two integers x and y (1 <= x <= y <= 1000), indicating the start number and the end number for the sum calculation. The second part is a description for the abacus after you finish the calculation. This part consists of 8 lines and each line consists of 6 characters. Each character is one of 'o' (bead), '' (rod) and '' (separator). The first two lines represent the upper beads. The third line always consists of '', representing the separator. The fourth to the eighth lines represent the lower beads. One column represents one rod. Exactly one '' appears in the upper part and one '' appears in the lower part in each rod. All the input represents a valid abacus. Cases are separated by one blank line. Output If there is no mistake in the calculation, output "No mistake", else output "Mistake". Sample Input 3 1 3 ooooo o  o ooooo oooooo oooooo oooooo 2 4 oooooo   o oooooo ooooo oooooo oooooo 20 21 oooooo   oo ooooo oooooo oooooo ooooo Sample Output No mistake Mistake No mistake Author: HANG, Hang Contest: The 9th Zhejiang University Programming Contest 