Metro

题意翻译

### 题目描述 Alice今天过生日,所以她邀请了她的好朋友Bob。现在Bob需要找到一种方法前去Alice家。 在Alice和Bob住的城市里,第一条地铁线正在施工中,仍处于试运行阶段。现在的地铁线有n个车站,编号从1至n。Bob住在1号站附近,Alice住在s号站附近。这条地铁线有两条轨道。第一条从1至n行驶,另一条则反之。当一辆车到达终点后,它会直接前去车辆段(停车场),所以Bob不可以坐到头后继续坐在车上。 有一些车站只是部分打开,而某些车站则完全没有打开。Bob取到了他要去拜访Alice时所有车站的开关情况。如果一个车站在某轨道上是关闭的,则列车在经过此车站时,会不加停靠的直接开过去。 在Bob研究了一会时间表后,他发现去参加Alice的Party可能会不一般的困难。请帮助Bob确定他应该坐地铁还是换一种交通方式去拜访Alice。 ### 输入输出格式 #### **输入格式:** 第一行: n和s。意义同上。 第二行: n个整数,对应a111,a222,...,annn。即第i个车站在轨道1(从1至n)上的开关情况(0是关,1是开) 第二行: n个整数,对应b111,b222,...,bnnn。即第i个车站在轨道2(从n至1)上的开关情况(0是关,1是开) #### **输出格式:** 如果Bob可以用地铁达到Alice家,输出```Yes```。否则输出```No```。(大小写爱咋搞咋搞)

题目描述

Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home. In the city in which Alice and Bob live, the first metro line is being built. This metro line contains $ n $ stations numbered from $ 1 $ to $ n $ . Bob lives near the station with number $ 1 $ , while Alice lives near the station with number $ s $ . The metro line has two tracks. Trains on the first track go from the station $ 1 $ to the station $ n $ and trains on the second track go in reverse direction. Just after the train arrives to the end of its track, it goes to the depot immediately, so it is impossible to travel on it after that. Some stations are not yet open at all and some are only partially open — for each station and for each track it is known whether the station is closed for that track or not. If a station is closed for some track, all trains going in this track's direction pass the station without stopping on it. When the Bob got the information on opened and closed stations, he found that traveling by metro may be unexpectedly complicated. Help Bob determine whether he can travel to the Alice's home by metro or he should search for some other transport.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ s $ ( $ 2 \le s \le n \le 1000 $ ) — the number of stations in the metro and the number of the station where Alice's home is located. Bob lives at station $ 1 $ . Next lines describe information about closed and open stations. The second line contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ a_i = 0 $ or $ a_i = 1 $ ). If $ a_i = 1 $ , then the $ i $ -th station is open on the first track (that is, in the direction of increasing station numbers). Otherwise the station is closed on the first track. The third line contains $ n $ integers $ b_1, b_2, \ldots, b_n $ ( $ b_i = 0 $ or $ b_i = 1 $ ). If $ b_i = 1 $ , then the $ i $ -th station is open on the second track (that is, in the direction of decreasing station numbers). Otherwise the station is closed on the second track.

输出格式


Print "YES" (quotes for clarity) if Bob will be able to commute to the Alice's home by metro and "NO" (quotes for clarity) otherwise. You can print each letter in any case (upper or lower).

输入输出样例

输入样例 #1

5 3
1 1 1 1 1
1 1 1 1 1

输出样例 #1

YES

输入样例 #2

5 4
1 0 0 0 1
0 1 1 1 1

输出样例 #2

YES

输入样例 #3

5 2
0 1 1 1 1
1 1 1 1 1

输出样例 #3

NO

说明

In the first example, all stations are opened, so Bob can simply travel to the station with number $ 3 $ . In the second example, Bob should travel to the station $ 5 $ first, switch to the second track and travel to the station $ 4 $ then. In the third example, Bob simply can't enter the train going in the direction of Alice's home.