Under construction

Still being built. Things may change

Hamburger

Interview

Time limit1sMemory limit1024 MB

Summary
Given a string S of bread, patty, lettuce, and tomato, check whether it is a valid hamburger: bread at both ends, no equal neighbors, and counts within A, B, C, D.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

haru_101 has AA pieces of bread, BB patties, CC lettuce leaves, and DD tomato slices, all of the same kind. Stack the ingredients under the following rules, and call the result a tasty hamburger.

  • Stack the ingredients from bottom to top.
  • The bottom ingredient and the top ingredient must both be bread.
  • Two adjacent ingredients cannot be the same.
  • Not every ingredient has to be used, but the hamburger must be made only from the ingredients on hand.

haru_101 wrote the hamburger to make as a string SS. Write a program that determines whether this hamburger is a tasty hamburger.

Input

The first line contains the length NN of the string SS.

The second line contains the integers AA, BB, CC, and DD, separated by spaces.

The third line contains the string SS, which consists only of the lowercase letters a, b, c, and d. The leftmost character of SS is the bottom ingredient, and the rightmost character is the top ingredient. a is bread, b is a patty, c is lettuce, and d is a tomato.

Output

Print Yes if the hamburger made from SS is a tasty hamburger. Otherwise, print No.

Constraints

  • 1≤N≤100 0001 \leq N \leq 100\,000
  • 1≤A+B+C+D≤100 0001 \leq A+B+C+D \leq 100\,000
  • AA, BB, CC, and DD are non-negative integers

Examples2

  1. Example 1

    Input
    5
    2 1 1 1
    abdca
    
    Expected output
    Yes
    
  2. Example 2

    Input
    2
    2 2 1 0
    aa
    
    Expected output
    No