QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#18286. Morning Roll Call

Statistics

At KSA, the morning roll call is conducted in the cafeteria in the form of an attendance check. There are a total of $N \cdot M$ students at KSA, and each student is assigned a distinct number from $1$ to $N \cdot M$. The attendance sheet is arranged in $N$ rows and $M$ columns, with students' numbers written in the cells. Each student finds their own number and draws a circle on it to indicate participation in the morning roll call. In the cell of the $i$-th row and $j$-th column, the number $i + N(j-1)$ is written. Each number can be circled at most once.

problem_18286_2.png

However, some lazy students have started asking their friends to attend roll call for them. A student who attends roll call for someone else quickly draws two circles around their number and the other student's number while the dorm supervisor is not watching. To avoid being caught, a student can only attend for another student if their numbers differ by exactly $1$ and their cells on the attendance sheet share a side.

Given the current attendance status of the students, determine the minimum number of additional students who must come so that attendance for all students can be completed.

Input

The first line contains two space-separated integers $N$ and $M$.

The $i$-th line of the following $N$ lines contains a string $S_i$. Each $S_i$ is a string of length $M$ consisting only of characters O and X.

If the $j$-th character of $S_i$ is O, then student number $i+N(j-1)$ has already completed the morning roll call. If it is X, then student number $i+N(j-1)$ has not yet completed the morning roll call.

Output

On the first line, print $k$, the minimum number of students who must come to the cafeteria so that every student's roll call can be completed.

Print one of the following on each of the next $k$ lines. If the student only completes their own roll call, print $1$ and their number, separated by a space. If the student attends roll call for someone else, print $2$ and the two students' numbers, separated by spaces.

The order of the student numbers and the $k$ lines does not matter. If there are multiple solutions, print any of them.

Constraints

  • $1 \le N, M \le 100$
  • At least one of $S_i$ contains an X

Scoring

No. Points Constraints
1 20 $M = 1$
2 80 No additional constraints

Examples

Input 1

3 2
XO
XX
XO

Output 1

3
1 3
2 1 2
1 5

Input 2

5 1
O
X
X
X
O

Output 2

2
1 2
2 4 3

Input 3

1 4
XXXX

Output 3

2
2 2 1
2 3 4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.