# Mirror Maze

## Problem Description

You are given a grid of $ R $ rows (numbered from $ 1 $ to $ R $ from north to south) and $ C $ columns (numbered from $ 1 $ to $ C $ from west to east). Every cell in this grid is a square of the same size. The cell located at row $ r $ and column $ c $ is denoted as $ (r, c) $ . Each cell can either be empty or have a mirror in one of the cell's diagonals. Each mirror is represented by a line segment. The mirror is type $ 1 $ if it is positioned diagonally from the southwest corner to the northeast corner of the cell, or type $ 2 $ for the other diagonal.

These mirrors follow the law of reflection, that is, the angle of reflection equals the angle of incidence. Formally, for type $ 1 $ mirror, if a beam of light comes from the north, south, west, or east of the cell, then it will be reflected to the west, east, north, and south of the cell, respectively. Similarly, for type $ 2 $ mirror, if a beam of light comes from the north, south, west, or east of the cell, then it will be reflected to the east, west, south, and north of the cell, respectively.

 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2045M/5f7b63f0fb5656735a6c59d6b7204c8e210c6d4c.png)You want to put a laser from outside the grid such that all mirrors are hit by the laser beam. There are $ 2 \cdot (R+C) $ possible locations to put the laser:

- from the north side of the grid at column $ c $ , for $ 1 \leq c \leq C $ , shooting a laser beam to the south;
- from the south side of the grid at column $ c $ , for $ 1 \leq c \leq C $ , shooting a laser beam to the north;
- from the east side of the grid at row $ r $ , for $ 1 \leq r \leq R $ , shooting a laser beam to the west; and
- from the west side of the grid at row $ r $ , for $ 1 \leq r \leq R $ , shooting a laser beam to the east.

 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2045M/29c68e47c3b155b917aa2d4237fa93819b498fc4.png)Determine all possible locations for the laser such that all mirrors are hit by the laser beam.

## Input Format

The first line consists of two integers $ R $ $ C $ ( $ 1 \leq R, C \leq 200 $ ).

Each of the next $ R $ lines consists of a string $ S_r $ of length $ C $ . The $ c $ -th character of string $ S_r $ represents cell $ (r, c) $ . Each character can either be . if the cell is empty, / if the cell has type $ 1 $ mirror, or \\ if the cell has type $ 2 $ mirror. There is at least one mirror in the grid.

## Output Format

Output a single integer representing the number of possible locations for the laser such that all mirrors are hit by the laser beam. Denote this number as $ k $ .

If $ k > 0 $ , then output $ k $ space-separated strings representing the location of the laser. Each string consists of a character followed without any space by an integer. The character represents the side of the grid, which could be N, S, E, or W if you put the laser on the north, south, east, or west side of the grid, respectively. The integer represents the row/column number. You can output the strings in any order.

## Sample #1

### Sample Input #1

```
4 4
.//.
.\\.
.\/.
....
```

### Sample Output #1

```
2
N3 W2
```

## Sample #2

### Sample Input #2

```
4 6
./..\.
.\...\
./../\
......
```

### Sample Output #2

```
2
E3 S2
```

## Sample #3

### Sample Input #3

```
4 4
....
./\.
.\/.
....
```

### Sample Output #3

```
0
```

## Hint

Explanation for the sample input/output #1

The following illustration shows one of the solutions of this sample.

 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2045M/e36d02e4bf94a08c27da9c9fd00e9bc42d7a4647.png)Explanation for the sample input/output #2

The following illustration shows one of the solutions of this sample.

 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2045M/35fe527ce8ee213e9ba2c6ba34c9f6c589c7585c.png)

## Limit



Time Limit
1.00s

Memory Limit
1000.00MB

Tags: brute force, dfs and similar, graphs, implementation
Difficulty: 1800