logo AlgoBeat OnlineJudge
登录 注册

#215327. [SWERC 2022] Controllers

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 . The game is composed of rounds. For each , the -th round works as follows.

On the screen, a symbol 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 written on it: your score will increase by if the symbol was and will decrease by if the symbol was . After you press the button, the round ends.

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

Over the years, your grandparents bought many different controllers, so you have of them. The two buttons on the -th controller have the numbers and 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 ( ) — the number of rounds.

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

The third line contains an integer ( ) — the number of controllers.

The following lines contain two integers and each ( ) — the numbers on the buttons of controller .

输出格式

Output lines. On line print if the game is winnable using controller , otherwise print .

样例

样例输入 1

8
+-+---+-
5
2 1
10 3
7 9
10 10
5 3

样例输出 1

YES
NO
NO
NO
YES

样例输入 2

6
+-++--
2
9 7
1 1

样例输出 2

YES
YES

样例输入 3

20
+-----+--+--------+-
2
1000000000 99999997
250000000 1000000000

样例输出 3

NO
YES

数据范围与提示

In the first sample, one possible way to get score using the first controller is by pressing the button with numnber in rounds , , , , and , and pressing the button with number in rounds and . It is possible to show that there is no way to get a score of using the second controller.