The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.
You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
Constraints
1≤A,B≤5
|S|=A+B+1
S consists of - and digits from 0 through 9.
Input
Input is given from Standard Input in the following format:
A B
S
Output
Print Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.
Examples
Input
3 4
269-6650
Output
Yes
Input
1 1
Output
No
Input
1 2
7444
Output
No
Assistant
We need to solve problem: given A and B, and string S, check if:
length is A+B+1
character at position A+1 (1-indexed) is '-'
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Constraints: A,B between 1 and 5 inclusive. |S| = A+B+1. S consists of '-' and digits.
Approach: read A, B, S. Check length: if len(S) != A+B+1 => No. Then check S[A] (0-index) == '-'. Then check all chars except that one are digits.
Implementation in Python: use str.isdigit().
Edge cases: if hyphen appears elsewhere? The condition says only that character must be hyphen; other characters must be digits. So if hyphen appears elsewhere, then it's not a digit, so should be No. So we check all i != A, S[i].isdigit().
Print "Yes" or "No" accordingly.
Simple.
Let's test examples:
Example1: A=3,B=4, S="269-6650": len=7 = 3+4? Actually 3+4=7, but plus 1? Wait: A+B+1? Actually format says length is A+B+1? The statement: "The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9." So length = A+B+1. So if A=3,B=4, length = 3+4+1=8? But example S "269-6650" has length 8? Let's count: 2,6,9,-,6,6,5,0 = 8. Yes correct. So length condition: len(S) should be A+B+1. In code, we should compute expected = A+B+1. So we must be careful: The input format: "A B" then S. So A and B are given. So expected length = A+B+1. Good.
In the condition, hyphen is at (A+1)-th character. That means index A (0-index) is hyphen.
So algorithm:
Read ints A, B.
Read string S.
if len(S) != A+B+1: print("No") and return.
if S[A] != '-': print("No") and return.
For i in range(len(S)):
if i != A and not S[i].isdigit(): print("No") and return.
print("Yes").
That's it.
But note: constraint says S consists of '-' and digits, but we can still check isdigit.
We'll implement solve().
Now produce final answer. ```python
import sys
def solve() -> None:
data = sys.stdin.read().split()
if not data:
return
A = int(data[0])
B = int(data[1])
S = data[2]
code
# 1. length check
if len(S) != A + B + 1:
print("No")
return
# 2. hyphen at the correct position
if S[A] != '-':
print("No")
return
# 3. all other characters are digits
for i, ch in enumerate(S):
if i != A and not ch.isdigit():
print("No")
return
print("Yes")