2400: 【普及-】【P1205】方块转换

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

一块 lns="http://www.w3.org/1998/Math/MathML">× 正方形的黑白瓦片的图案要被转换成新的正方形图案。写一个程序来找出将原始图案按照以下列转换方法转换成新图案的最小方式:

  • 转 lns="http://www.w3.org/1998/Math/MathML">90°:图案按顺时针转 lns="http://www.w3.org/1998/Math/MathML">90°

  • 转 lns="http://www.w3.org/1998/Math/MathML">180°:图案按顺时针转 lns="http://www.w3.org/1998/Math/MathML">180°

  • 转 lns="http://www.w3.org/1998/Math/MathML">270°:图案按顺时针转 lns="http://www.w3.org/1998/Math/MathML">270°

  • 反射:图案在水平方向翻转(以中央铅垂线为中心形成原图案的镜像)。

  • 组合:图案在水平方向翻转,然后再按照 lns="http://www.w3.org/1998/Math/MathML">13 之间的一种再次转换。

  • 不改变:原图案不改变。

  • 无效转换:无法用以上方法得到新图案。

如果有多种可用的转换方法,请选择序号最小的那个。

只使用上述 lns="http://www.w3.org/1998/Math/MathML">7 个中的一个步骤来完成这次转换。

输入

第一行一个正整数 lns="http://www.w3.org/1998/Math/MathML">

然后 lns="http://www.w3.org/1998/Math/MathML"> 行,每行 lns="http://www.w3.org/1998/Math/MathML"> 个字符,全部为 @ 或 -,表示初始的正方形。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,每行 lns="http://www.w3.org/1998/Math/MathML"> 个字符,全部为 @ 或 -,表示最终的正方形。

输出

单独的一行包括 lns="http://www.w3.org/1998/Math/MathML">17 之间的一个数字(在上文已描述)表明需要将转换前的正方形变为转换后的正方形的转换方法。

样例输入 复制

3
@-@
---
@@-
@-@
@--
--@

样例输出 复制

1

提示

【数据范围】
对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">110