Codeforces Round 562 (Div. 2)
E
And Reachability
Codeforces
未评级
原题
← D→
翻译中…

Toad Pimple has an array of integers $a_1, a_2, \ldots, a_n$.

翻译中…

We say that $y$ is reachable from $x$ if $x \lt y$ and there exists an integer array $p$ such that $x = p_1 \lt p_2 \lt \ldots \lt p_k=y$, and $a_{p_i}\, \&\, a_{p_{i+1}} \gt 0$ for all integers $i$ such that $1 \leq i \lt k$.

翻译中…

Here $\&$ denotes the bitwise AND operation.

翻译中…

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

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $q$ ($2 \leq n \leq 300\,000$, $1 \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 $n$ space-separated integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 300\,000$) — the given array.

翻译中…

The next $q$ lines contain two integers each. The $i$-th of them contains two space-separated integers $x_i$ and $y_i$ ($1 \leq x_i \lt y_i \leq n$). You need to check if $y_i$ is reachable from $x_i$.

翻译中…

Output

翻译中…

Output $q$ lines. In the $i$-th of them print "Shi" if $y_i$ is reachable from $x_i$, otherwise, print "Fou".

翻译中…

Note

翻译中…

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

翻译中…

样例

Input #1
5 3
1 3 0 2 1
1 3
2 4
1 4
Output #1
Fou
Shi
Shi
InputCopy OutputCopy
题目信息
题号
1169E
时间限制
3 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。