P21440 [HackerEarth] There are n clocks in the Pradnya Planet which beep after different time periods.
普及
题目描述

There are n clocks in the Pradnya Planet which beep after different time periods.
The clocks are represented as C1, C2, ... Cn and their respective time periods
by T1, T2, T3, ... Tn.
Each clock beeps with the intensity of 1. If k clocks beep at the same time, it
is counted as one beep of intensity k.
There are p aliens in the pradnya world who are sleeping at time t=0.
These p aliens are denoted by A1, A2, ... Ap.
All the aliens are insomniac but all in a different way.
An alien wakes up at time t, either if the number of beeps completed before or at the time t exceeds a particular value(Beep Value), or if the intensity of any beep before or at time t exceeds a particular value(Intensity Value).
Now, the aliens go to their "Big Boss" with a time t.
The "Big Boss" then tells whether the alien will wake up till that time t.
Since the queries(q) of the aliens are too large, help the "Big Boss" to answer the queries.

Note: A clock Ci with time period Ti beeps at time: Ti, 2Ti, 3Ti, ... so on.

Input Format:
The first line contains an integer n denoting the number of clocks.

The next line contains n space separated integers denoting the time periods of the n respective clocks.

The next line contains p denoting the number of aliens.

The next p lines contain two space separated integers b and i, denoting the Beep Value and Intensity Value of the respective aliens

The next line contains q denoting the number of queries.

The next q lines contain two space separated integers in and t, denoting the alien Ain and the time t respectively.

Output Format:
For each of the q lines, output "Awake" if the alien Ain will awake before time t,
else output "Asleep", if the alien does not wake up before time t.

Constraints:
1 ≤ n ≤ 10^5
1 ≤ time period of any clock ≤ 10^3
1 ≤ p ≤ 10^3
1 ≤ q ≤ 10^5
1 ≤ i ≤ n
1 ≤ t ≤ 10^5
1 ≤ b ≤ tSAMPLE INPUT
3
1 2 3
3
3 3
3 1
4 2
3
1 3
2 3
3 2

SAMPLE OUTPUT
Asleep
Awake
Asleep

Explanation

At time t = 1, no of beeps = 1 and maximum intensity value is 1

At time t=2, no of beeps = 2 and maximum intensity value is 2

At time t=3, no of beeps = 3 and maximum intensity value is 3.

For the 1st query, the alien A1 will be asleep at t=3, because the no of beeps(3) do not exceed 3 and maximum intensity does not exceed 3.

For the 2nd query, the alien A2 will wake up at t=3, because the maximum intensity(2) exceeds 1.

For the 3rd query, the alien A3 will be asleep at t=2, because the no of beeps(2) do not exceed 4 and maximum intensity(2) does not exceed 2.

输入格式

见题面

输出格式

见题面

样例输入
100 50 815 426 646 339 103 47 786 172 824 326 584 701 58 110 333 822 558 152 435 105 942 852 484 611 306 948 591 755 758 185 837 219 744 985 653 813 599 912 992 440 448 355 678 418 884 876 861 50 169 765 411 752 112 432 465 52 38 130 124 95 3 49 20 690 254 943 179 222 220 429 419 997 503 926 653 878 694 709 351 22 780 664 6 702 789 338 615 125 143 561 816 965 682 842 401 698 445 219 496 100 79 483 39 609 99 866 75 754 28 597 46 491 27 361 83 208 59 970 90 781 5 22 78 567 99 556 65 966 27 142 65 356 60 50 27 169 63 200 60 518 89 928 80 941 28 188 80 252 69 962 87 769 16 815 23 495 63 259 100 329 26 117 52 668 24 191 8 848 6 59 47 138 93 981 44 815 48 315 48 239 61 880 69 760 27 245 97 981 8 326 39 127 4 270 84 693 72 461 83 568 88 562 69 779 4 514 21 410 54 217 52 636 27 380 2 468 2 738 74 798 59 338 12 849 6 391 46 568 75 570 51 67 78 832 60 637 90 897 77 843 28 700 40 137 62 751 68 304 75 705 29 569 12 853 38 976 24 878 37 454 10 959 47 788 1 304 34 551 40 983 45 203 4 700 74 957 98 604 5 451 57 170 4 417 85 608 90 239 23 618 69 14 44 944 14 31 67 986 22 405 100 65 443 20 237 91 211 23 686 8 858 74 491 82 968 95 505 16 562 40 292 80 833 2 541 53 753 71 601 63 382 53 483 84 89 44 599 35 302 40 570 19 143 59 630 100 127 3 516 35 477 7 906 91 551 97 419 95 511 89 792 5 721 1 187 48 348 67 581 20 342 87 743 2 245 92 765 22 293 54 213 21 989 10 256 26 669 61 748 52 125 88 890 68 522 26 367 62 61 68 551 92 652 72 301 67 898 56 546 7 642 27 879 47 184 83 518 93 579 55 996 53 6 8 705 85 376 92 564 99 770 30 497 2 477 10 771 7 925 55 436 88 336 74 768 32 438 70 812 48 306 23 469 51 77 84 476 91 158 82 39 2 24 31 146 75 666 4 764 37 146 85 703 4 102 64 355 11 582 25 650 20 648 7 34 14 544 66 289 7 339 34 783 51 456 85 741 28 75 98 895
样例输出
Asleep Asleep Asleep Asleep Asleep Asleep Asleep Asleep Asleep Asleep