Alex has a habit of falling asleep during lectures! In order to complete the day’s homework, he must determine if he has any friends that stayed awake so he can borrow their notes.

There are other students in Alex’s class, and each student has a distinct ID number from to . You are given a string, , of binary characters where the character denotes whether the student slept during the lecture or not. If the character is a , then the student stayed awake and took notes; otherwise, the character is a which indicates the student fell asleep and did not take notes.

Alex has friends in his class and you are given a list of integers corresponding to their respective ID numbers. If Alex can borrow the lecture notes from one of his friends, print YES; otherwise, print NO.

Input Format

The first line contains two space-separated integers denoting the respective values of (the number of students in Alex’s class) and (Alex’s number of friends in the class).

The second line contains a single binary string (i.e., ‘s and ‘s) of length . If the character is a , then Alex can’t get notes from them; otherwise, it’s a , indicating the student took lecture notes.

The next line contains distinct space-separated integers where each integer denotes the ID number of one of Alex’s friends.

Constraints

Output Format

Print YES on a new line if Alex can get the lecture notes from one of his friends; otherwise, print NO.

Sample Input

3 2

101

1 3

Sample Output

NO

Explanation

There are other students in the class, and of them are Alex’s friends. Students and fell asleep, but student stayed awake. Alex is only friends with students and and, as they both fell asleep during the lecture, Alex cannot get notes from them. Thus, we print NO as our answer.

Solution:

package hack41;

import java.util.Scanner;

public class LectureNotes {

public static void main(String[] args) {

Scanner scan= new Scanner(System.in);

int n= scan.nextInt();

int k = scan.nextInt();

scan.nextLine();

String str=scan.nextLine();

char attendance[]=str.toCharArray();

String frnds=scan.nextLine();

String frndsFinal[]=frnds.split(” “);

/* for(int i=0;i<frndsFinal.length;i++)

System.out.println(frndsFinal[i]);

*/

int borrrow=0;

for(int j=0;j<frndsFinal.length;j++)

{

int frndId=Integer.parseInt(frndsFinal[j]);

if(attendance[frndId-1]==’0’)

{

borrrow=1;

break;

}

}

if(borrrow==1)

System.out.println(“YES”);

else

System.out.println(“NO”);

}

}