#abc269b. B - Rectangle Detection

B - Rectangle Detection

Score : 200200 points

问题描述

高桥按照以下方式生成了10个字符串S1,S2,,S10S_1,S_2,\dots,S_{10}

  • 首先,令Si(1i10)=S_i (1 \le i \le 10)= .......... (一行连续的10个.)。
  • 接着,选择四个整数AABBCCDD,满足所有以下条件。
    • 1AB101 \le A \le B \le 10
    • 1CD101 \le C \le D \le 10
  • 然后,对于满足所有以下条件的每一对整数(i,j)(i,j),将SiS_i的第jj个字符替换为#
    • AiBA \le i \le B
    • CjDC \le j \le D

已知按照上述方式生成的S1,S2,,S10S_1,S_2,\dots,S_{10}。找出高桥选择的整数AABBCCDD。 根据约束条件,可以证明这样的整数AABBCCDD唯一存在(答案只有一个)。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi generated 1010 strings S1,S2,,S10S_1,S_2,\dots,S_{10} as follows.

  • First, let Si(1i10)=S_i (1 \le i \le 10)= .......... (1010 .s in a row).
  • Next, choose four integers AA, BB, CC, and DD satisfying all of the following.
    • 1AB101 \le A \le B \le 10.
    • 1CD101 \le C \le D \le 10.
  • Then, for every pair of integers (i,j)(i,j) satisfying all of the following, replace the jj-th character of SiS_i with #.
    • AiBA \le i \le B.
    • CjDC \le j \le D.

You are given S1,S2,,S10S_1,S_2,\dots,S_{10} generated as above. Find the integers AA, BB, CC, and DD Takahashi chose.
It can be proved that such integers AA, BB, CC, and DD uniquely exist (there is just one answer) under the Constraints.

Constraints

  • S1,S2,,S10S_1,S_2,\dots,S_{10} are strings, each of length 1010, that can be generated according to the Problem Statement.

Input

The input is given from Standard Input in the following format:

S1S_1

S2S_2

\vdots

S10S_{10}

Output

Print the answer in the following format:

AA BB

CC DD

Sample Input 1

..........
..........
..........
..........
...######.
...######.
...######.
...######.
..........
..........

Sample Output 1

5 8
4 9

Here, Takahashi chose A=5A=5, B=8B=8, C=4C=4, D=9D=9.
This choice generates 1010 strings S1,S2,,S10S_1,S_2,\dots,S_{10}, each of length 1010, where the 44-th through 99-th characters of S5,S6,S7,S8S_5,S_6,S_7,S_8 are #, and the other characters are ..
These are equal to the strings given in the input.

Sample Input 2

..........
..#.......
..........
..........
..........
..........
..........
..........
..........
..........

Sample Output 2

2 2
3 3

Sample Input 3

##########
##########
##########
##########
##########
##########
##########
##########
##########
##########

Sample Output 3

1 10
1 10

update @ 2024/3/10 11:20:41