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.

Input

The first line contains two integers n and s (2 ≤ s ≤ n ≤ 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, …, 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, …, 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.

Output

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).

Examples

Input

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


Output

YES


Input

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


Output

YES


Input

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


Output

NO

Note

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.
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;
import java.io.IOException;import java.io.PrintStream;import java.io.PrintWriter;
import java.security.AccessControlException;import java.util.Arrays;import java.util.Collection;
import java.util.Comparator;import java.util.List;import java.util.Map;import java.util.Objects;
import java.util.Scanner;import java.util.TreeMap;import java.util.function.Function;
import java.util.stream.Collectors;import java.util.stream.IntStream;import java.util.stream.LongStream;
import java.util.stream.Stream;public class _p001055A {static public void main(final String[] args) 
throws IOException{p001055A._main(args);}
//begin p001055A.java
static private class p001055A extends Solver{public p001055A(){nameIn="in/900/p001055A.in"
;singleTest=true;}@Override public void solve()throws IOException{int n=sc.nextInt
();int s=sc.nextInt();if(sc.hasNextLine()){sc.nextLine();}int[]a=lineToIntArray(
);int[]b=lineToIntArray();boolean res=a[0]==1;if(res && a[s-1]==0){res=b[s-1]==1
 && IntStream.range(s,n).anyMatch(i->a[i]==1 && b[i]==1);}pw.println(res?"YES":"NO"
);}static public void _main(String[]args)throws IOException{new p001055A().run();
}}
//end p001055A.java
//begin net/leksi/contest/Pair.java
static private class Pair<K,V>{private K k;private V v;public Pair(final K t,final
 V u){this.k=t;this.v=u;}public K getKey(){return k;}public V getValue(){return 
v;}}
//end net/leksi/contest/Pair.java
//begin net/leksi/contest/Solver.java
static private abstract class Solver{protected String nameIn=null;protected String
 nameOut=null;protected boolean singleTest=false;protected boolean preprocessDebug
=false;protected boolean doNotPreprocess=false;protected PrintStream debugPrintStream
=null;protected Scanner sc=null;protected PrintWriter pw=null;final static String
 SPACE=" ";final static String SPACES="\\s+";private void process()throws IOException
{if(!singleTest){int t=lineToIntArray()[0];while(t-->0){solve();}}else{solve();}
}abstract protected void solve()throws IOException;protected int[]lineToIntArray
()throws IOException{return Arrays.stream(sc.nextLine().trim().split(SPACES)).mapToInt
(Integer::valueOf).toArray();}protected long[]lineToLongArray()throws IOException
{return Arrays.stream(sc.nextLine().trim().split(SPACES)).mapToLong(Long::valueOf
).toArray();}protected void run()throws IOException{boolean done=false;try{if(nameIn
!=null && new File(nameIn).exists()){try(FileInputStream fis=new FileInputStream
(nameIn);PrintWriter pw0=select_output();){done=true;sc=new Scanner(fis);pw=pw0;
process();}}}catch(IOException ex){}catch(AccessControlException ex){}if(!done){
try(PrintWriter pw0=select_output();){sc=new Scanner(System.in);pw=pw0;process()
;}}}private PrintWriter select_output()throws FileNotFoundException{if(nameOut!=
null){return new PrintWriter(nameOut);}return new PrintWriter(System.out);}public
 static Map<Integer,List<Integer>>mapi(final int[]a){return IntStream.range(0,a.
length).collect(()->new TreeMap<Integer,List<Integer>>(),(res,i)->{if(!res.containsKey
(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));}else{res.get(a[
i]).add(i);}},Map::putAll);}public static Map<Long,List<Integer>>mapi(final long
[]a){return IntStream.range(0,a.length).collect(()->new TreeMap<Long,List<Integer
>>(),(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors
.toList()));}else{res.get(a[i]).add(i);}},Map::putAll);}public static<T>Map<T,List
<Integer>>mapi(final T[]a){return IntStream.range(0,a.length).collect(()->new TreeMap
<T,List<Integer>>(),(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(
i).collect(Collectors.toList()));}else{res.get(a[i]).add(i);}},Map::putAll);}public
 static<T>Map<T,List<Integer>>mapi(final T[]a,Comparator<T>cmp){return IntStream
.range(0,a.length).collect(()->new TreeMap<T,List<Integer>>(cmp),(res,i)->{if(!res
.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));}else
{res.get(a[i]).add(i);}},Map::putAll);}public static Map<Integer,List<Integer>>mapi
(final IntStream a){int[]i=new int[]{0};return a.collect(()->new TreeMap<Integer
,List<Integer>>(),(res,v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect
(Collectors.toList()));}else{res.get(v).add(i[0]);}i[0]++;},Map::putAll);}public
 static Map<Long,List<Integer>>mapi(final LongStream a){int[]i=new int[]{0};return
 a.collect(()->new TreeMap<Long,List<Integer>>(),(res,v)->{if(!res.containsKey(v
)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));}else{res.get(v).add(
i[0]);}i[0]++;},Map::putAll);}public static<T>Map<T,List<Integer>>mapi(final Stream
<T>a,Comparator<T>cmp){int[]i=new int[]{0};return a.collect(()->new TreeMap<T,List
<Integer>>(cmp),(res,v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect
(Collectors.toList()));}else{res.get(v).add(i[0]);}},Map::putAll);}public static
<T>Map<T,List<Integer>>mapi(final Stream<T>a){int[]i=new int[]{0};return a.collect
(()->new TreeMap<T,List<Integer>>(),(res,v)->{if(!res.containsKey(v)){res.put(v,
Stream.of(i[0]).collect(Collectors.toList()));}else{res.get(v).add(i[0]);}},Map::
putAll);}public static List<int[]>listi(final int[]a){return IntStream.range(0,a
.length).mapToObj(i->new int[]{a[i],i}).collect(Collectors.toList());}public static
 List<long[]>listi(final long[]a){return IntStream.range(0,a.length).mapToObj(i->
new long[]{a[i],i}).collect(Collectors.toList());}public static<T>List<Pair<T,Integer
>>listi(final T[]a){return IntStream.range(0,a.length).mapToObj(i->new Pair<T,Integer
>(a[i],i)).collect(Collectors.toList());}public static List<int[]>listi(final IntStream
 a){int[]i=new int[]{0};return a.mapToObj(v->new int[]{v,i[0]++}).collect(Collectors
.toList());}public static List<long[]>listi(final LongStream a){int[]i=new int[]
{0};return a.mapToObj(v->new long[]{v,i[0]++}).collect(Collectors.toList());}public
 static<T>List<Pair<T,Integer>>listi(final Stream<T>a){int[]i=new int[]{0};return
 a.map(v->new Pair<T,Integer>(v,i[0]++)).collect(Collectors.toList());}public static
 String join(final int[]a){return Arrays.stream(a).mapToObj(Integer::toString).collect
(Collectors.joining(SPACE));}public static String join(final long[]a){return Arrays
.stream(a).mapToObj(Long::toString).collect(Collectors.joining(SPACE));}public static
<T>String join(final T[]a){return Arrays.stream(a).map(v->Objects.toString(v)).collect
(Collectors.joining(SPACE));}public static<T>String join(final T[]a,final Function
<T,String>toString){return Arrays.stream(a).map(v->toString.apply(v)).collect(Collectors
.joining(SPACE));}public static<T>String join(final Collection<T>a){return a.stream
().map(v->Objects.toString(v)).collect(Collectors.joining(SPACE));}public static
<T>String join(final Collection<T>a,final Function<T,String>toString){return a.stream
().map(v->toString.apply(v)).collect(Collectors.joining(SPACE));}public static<T
>String join(final Stream<T>a){return a.map(v->Objects.toString(v)).collect(Collectors
.joining(SPACE));}public static<T>String join(final Stream<T>a,final Function<T,
String>toString){return a.map(v->toString.apply(v)).collect(Collectors.joining(SPACE
));}public static<T>String join(final IntStream a){return a.mapToObj(Integer::toString
).collect(Collectors.joining(SPACE));}public static<T>String join(final LongStream
 a){return a.mapToObj(Long::toString).collect(Collectors.joining(SPACE));}public
 static List<Integer>list(final int[]a){return Arrays.stream(a).mapToObj(Integer
::valueOf).collect(Collectors.toList());}public static List<Integer>list(final IntStream
 a){return a.mapToObj(Integer::valueOf).collect(Collectors.toList());}public static
 List<Long>list(final long[]a){return Arrays.stream(a).mapToObj(Long::valueOf).collect
(Collectors.toList());}public static List<Long>list(final LongStream a){return a
.mapToObj(Long::valueOf).collect(Collectors.toList());}public static<T>List<T>list
(final Stream<T>a){return a.collect(Collectors.toList());}public static<T>List<T
>list(final T[]a){return Arrays.stream(a).collect(Collectors.toList());}}
//end net/leksi/contest/Solver.java
}
