Under construction

Still being built. Things may change

Pseudographical Recognizer

Time limit1sMemory limit128 MB

Summary
Given a small grid of line and dot characters, decide whether the drawn characters form exactly one connected straight segment.
Level

Easy3 of 10

Topics
Implementation, Simulation, Brute force
Solved
No attempts yet

Problem

A pseudographical image is a rectangular matrix made up of the characters ., -, |, \, and /.

The character . denotes empty space. A horizontal line segment is a run of - characters in adjacent cells of the same row. A vertical line segment is a run of | characters in adjacent cells of the same column. A diagonal line segment is a run of / or \ characters in adjacent cells along the same diagonal. A segment running from the top-left to the bottom-right (Northwest to Southeast) is drawn with \, and a segment running from the bottom-left to the top-right (Southwest to Northeast) is drawn with /. A single character on its own also counts as a line segment.

Given a pseudographical image, determine whether it contains exactly one line segment — horizontal, vertical, or diagonal.

Input

The input contains several test cases. The first line contains the number of test cases TT (1≤T≤1001 \le T \le 100). The descriptions of the test cases follow. The first line of a test case description contains two integers NN and MM (1≤N,M≤101 \le N, M \le 10) — the number of rows and columns of the matrix. Each of the next NN lines contains exactly MM characters, each one of ., -, |, \, or /.

Output

For each test case, print a single line containing CORRECT if the image contains exactly one line segment, or INCORRECT otherwise.

Examples3

  1. Example 1

    Input
    5
    5 5
    .....
    \....
    .\...
    ..\..
    .....
    3 3
    /..
    ./.
    ../
    3 6
    .|....
    .|.---
    .|....
    3 3
    ...
    ...
    ...
    1 1
    /
    
    Expected output
    CORRECT
    INCORRECT
    INCORRECT
    INCORRECT
    CORRECT
    
  2. Example 2

    Input
    1
    1 3
    ---
    
    Expected output
    CORRECT
    
  3. Example 3

    Input
    1
    3 1
    |
    |
    |
    
    Expected output
    CORRECT