Jumping on Walls

题意翻译

### 题目描述 瓦西亚在和忍者玩电脑游戏。在这个关卡,瓦西亚需要操控忍者走出一个很深的峡谷。 峡谷由两面垂直于地面且互相平行的墙组成,它们的高度为$n$米。我们将这些墙分成许多$1$米长的区域,并从下到上用$1$到$n$的正整数对它们进行编号。有些地方是安全的,忍者可以爬上去。有些地方石头很尖锐,忍者不能待在那里。我们称这些地区为危险地区。 最初忍者在左墙的最下方。他每秒可以执行以下操作之一: * 向上爬一个区域; * 向下爬一个区域; * 跳到对面的墙上。忍者会跳到比他当前所在高度高$k$米的地方。更准确地说,如果在跳跃之前忍者位于一面墙的区域$x$,那么在跳跃之后,他位于另一面墙的区域$x + k$。 如果在某个时间点忍者到达了一个高度大于$n$的区域,那么忍者就可以从峡谷中出来了。 但峡谷被水淹没了,每秒水位会上升一米。最初,水位达到区域$1$的下边界。忍者不能待在被水淹没的地方。忍者和水轮流移动——首先忍者行动,然后水上升一米,然后忍者再行动,以此类推。 如果忍者可以离开峡谷,那这个关卡就完成了。 在几次失败的尝试之后,瓦西亚开始怀疑是否有可能完成这一关卡。请回答他的问题。 ### 输入输出格式 ##### 输入格式: 第一行包含两个整数$n$和$k$ $(1 \leq n ,k \leq 10^5)$——峡谷的高度和忍者可以跳跃的高度 第二行包含左墙的描述——一个长度为$n$个字符的字符串。第$i$个字符表示墙的区域$i$的状态:字符“X”表示危险区域,“-”表示安全区域。 第三行以相同的格式描述了右墙。 数据保证左墙的第一个区域不是危险区域。 ##### 输出格式: 如果忍者能从峡谷中出来,打印“YES”(不带引号),否则,打印“NO”(不带引号)。 ### 说明 在第一个样例中,忍者可以先跳到右边的墙,然后沿着右边的墙往下走一米,然后跳到左边的墙。再跳跃一次忍者就可以离开峡谷。 在第二个样例中,忍者是无法离开峡谷的。

题目描述

Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon. The canyon consists of two vertical parallel walls, their height is $ n $ meters. Let's imagine that we split these walls into $ 1 $ meter-long areas and number them with positive integers from $ 1 $ to $ n $ from bottom to top. Some areas are safe and the ninja can climb them. Others are spiky and ninja can't be there. Let's call such areas dangerous. Initially the ninja is on the lower area of the left wall. He can use each second to perform one of the following actions: - climb one area up; - climb one area down; - jump to the opposite wall. That gets the ninja to the area that is exactly $ k $ meters higher than the area he jumped from. More formally, if before the jump the ninja is located at area $ x $ of one wall, then after the jump he is located at area $ x+k $ of the other wall. If at some point of time the ninja tries to get to an area with a number larger than $ n $ , then we can assume that the ninja got out of the canyon. The canyon gets flooded and each second the water level raises one meter. Initially the water level is at the lower border of the first area. Ninja cannot be on the area covered by water. We can assume that the ninja and the water "move in turns" — first the ninja performs some action, then the water raises for one meter, then the ninja performs one more action and so on. The level is considered completed if the ninja manages to get out of the canyon. After several failed attempts Vasya started to doubt whether it is possible to complete the level at all. Help him answer the question.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1<=n,k<=10^{5} $ ) — the height of the canyon and the height of ninja's jump, correspondingly. The second line contains the description of the left wall — a string with the length of $ n $ characters. The $ i $ -th character represents the state of the $ i $ -th wall area: character "X" represents a dangerous area and character "-" represents a safe area. The third line describes the right wall in the same format. It is guaranteed that the first area of the left wall is not dangerous.

输出格式


Print "YES" (without the quotes) if the ninja can get out from the canyon, otherwise, print "NO" (without the quotes).

输入输出样例

输入样例 #1

7 3
---X--X
-X--XX-

输出样例 #1

YES

输入样例 #2

6 2
--X-X-
X--XX-

输出样例 #2

NO

说明

In the first sample the ninja should first jump to the right wall, then go one meter down along the right wall, then jump to the left wall. The next jump can get the ninja from the canyon. In the second sample there's no way the ninja can get out of the canyon.