Count ways to direct each belt on a toroidal grid so no two lemmings ever share a square, modulo 1000003.
Medium7GraphUnion-findCombinatoricsNo attempts yetTime limit5sMemory limit512 MBThe floor of the lemming factory is an R x C grid. Every square holds one conveyor belt, oriented up-down, left-right, or along one of the two diagonals. A belt runs forwards or backwards along its orientation, and you choose the direction of each belt independently.

Right now one lemming stands at the center of each square. When the belts start, every lemming moves in the direction of the belt under him until he reaches the center of a neighboring square. All of these moves happen at the same time and take exactly one second. After that second the lemmings stand on new squares and the same thing happens again, forever, or at least until you turn the belts off.
If two lemmings ever reach the center of the same square at the same moment, they are stuck together from then on. Your goal is to pick a direction for every belt so that this never happens.
Here are two ways to pick directions for the layout above.

In both of them, no two lemmings ever reach the center of the same square at the same time.
Given a floor layout, count N, the number of ways to pick a direction for every belt so that no two lemmings are ever at the center of the same square at the same time. The answer can be very large, so print it modulo 1000003.
The first line contains the number of test cases T. T test cases follow. The first line of each test case contains the positive integers R and C.
The next R lines each contain a string of C characters taken from |, -, /, \. Each character is the orientation of the belt in that square.
| is a belt that moves up or down.- is a belt that moves left or right./ is a belt that moves up-right or down-left.\ is a belt that moves up-left or down-right.For each test case, print one line in the form "Case #x: M", where x is the test case number starting from 1 and M is the remainder of N divided by 1000003.