아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Controllers

시간 제한2초메모리 제한1024 MB

요약
각 컨트롤러마다 n개의 더하기와 빼기 라운드에서 두 버튼 값 중 하나를 골라 최종 점수를 0으로 만들 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
수학, 정수론, 누적 합, 이분 탐색
정답자
아직 제출이 없습니다

문제

You are at your grandparents’ house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.

Initially, your score is 00. The game is composed of nn rounds. For each 1≤i≤n1 ≤ i ≤ n, the ii-th round works as follows.

On the screen, a symbol s_is\_i appears, which is either + (plus) or - (minus). Then you must press one of the two buttons on the controller once. Suppose you press a button with the number xx written on it: your score will increase by xx if the symbol was + and will decrease by xx if the symbol was -. After you press the button, the round ends.

After you have played all nn rounds, you win if your score is 00.

Over the years, your grandparents bought many different controllers, so you have qq of them. The two buttons on the jj-th controller have the numbers a_ja\_j and b_jb\_j written on them. For each controller, you must compute whether you can win the game playing with that controller.

입력

The first line contains a single integer nn (1≤n≤2⋅1051 ≤ n ≤ 2 \cdot 10^5) — the number of rounds.

The second line contains a string ss of length nn — where s_is\_i is the symbol that will appear on the screen in the ii-th round. It is guaranteed that ss contains only the characters + and -.

The third line contains an integer qq (1≤q≤1051 ≤ q ≤ 10^5) — the number of controllers.

The following qq lines contain two integers a_ja\_j and b_jb\_j each (1≤a_j,b_j≤1091 ≤ a\_j , b\_j ≤ 10^9) — the numbers on the buttons of controller jj.

출력

Output qq lines. On line jj print YES if the game is winnable using controller jj, otherwise print NO.

예제3

  1. 예제 1

    입력
    8
    +-+---+-
    5
    2 1
    10 3
    7 9
    10 10
    5 3
    
    예상 출력
    YES
    NO
    NO
    NO
    YES
    
  2. 예제 2

    입력
    6
    +-++--
    2
    9 7
    1 1
    
    예상 출력
    YES
    YES
    
  3. 예제 3

    입력
    20
    +-----+--+--------+-
    2
    1000000000 99999997
    250000000 1000000000
    
    예상 출력
    NO
    YES