CF1168C.And Reachability

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Toad Pimple has an array of integers a1,a2,,ana_1, a_2, \ldots, a_n .

We say that yy is reachable from xx if x<yx<y and there exists an integer array pp such that x=p1<p2<<pk=yx = p_1 < p_2 < \ldots < p_k=y , and api&api+1>0a_{p_i}\, \&\, a_{p_{i+1}} > 0 for all integers ii such that 1i<k1 \leq i < k .

Here &\& denotes the bitwise AND operation.

You are given qq pairs of indices, check reachability for each of them.

输入格式

The first line contains two integers nn and qq ( 2n3000002 \leq n \leq 300\,000 , 1q3000001 \leq q \leq 300\,000 ) — the number of integers in the array and the number of queries you need to answer.

The second line contains nn space-separated integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai3000000 \leq a_i \leq 300\,000 ) — the given array.

The next qq lines contain two integers each. The ii -th of them contains two space-separated integers xix_i and yiy_i ( 1xi<yin1 \leq x_i < y_i \leq n ). You need to check if yiy_i is reachable from xix_i .

输出格式

Output qq lines. In the ii -th of them print "Shi" if yiy_i is reachable from xix_i , otherwise, print "Fou".

输入输出样例

  • 输入#1

    5 3
    1 3 0 2 1
    1 3
    2 4
    1 4
    

    输出#1

    Fou
    Shi
    Shi
    

说明/提示

In the first example, a3=0a_3 = 0 . You can't reach it, because AND with it is always zero. a2&a4>0a_2\, \&\, a_4 > 0 , so 44 is reachable from 22 , and to go from 11 to 44 you can use p=[1,2,4]p = [1, 2, 4] .

首页