#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, q, arr[300010], dp[300010][20];
//dp[i][j] : i번 index에서부터 j번 bit가 켜지는 최소 index
// prv[i][j] : 현재 i번 비트를 가지고 있을때 j번 비트가 켜지는 최소 index
int prv[20][20];
int main() {
	memset(dp, 0x3f, sizeof dp);
	memset(prv, 0x3f, sizeof prv);
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					if (arr[i] & (1 << k))
						prv[j][k] = i;
				}
			}
		}
		for (int j = 0; j <= 19; j++) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					dp[i][k] = min(dp[i][k], prv[j][k]);
				}
			}
		}
		for (int j = 0; j <= 19; j++) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					prv[j][k] = min(dp[i][k], prv[j][k]);
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d번 : ", i);
		for (int j = 0; j <= 4; j++) {
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}
	for (int i = 0; i < q; ++i) {
		int a, b, temp = 1e9;
		scanf("%d %d", &a, &b);
		for (int j = 0; j <= 19; j++) {
			if (arr[b - 1] & (1 << j)) {
				temp = min(temp, dp[a - 1][j]);
			}
		}
		if (temp <= b - 1) {
			printf("Shi\n");
		}
		else printf("Fou\n");
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, cnt, q, arr[300010], dp[300010];
int prv[20];
int main() {
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		int val = arr[i];
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				val |= prv[j];
			}
		}
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= val;
			}
		}
		dp[i] = val;
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (dp[a-1] & arr[b-1])printf("Shi\n");
		else printf("Fou\n");
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, q, arr[300010], dp[300010][20];
//dp[i][j] : i번 index에서부터 j번 bit가 켜지는 최소 index
// prv[i][j] : 현재 i번 비트를 가지고 있을때 j번 비트가 켜지는 최소 index
int prv[20][20], t[20];
int main() {
	memset(dp, 0x3f, sizeof dp);
	memset(prv, 0x3f, sizeof prv);
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		memset(t, 0x3f, sizeof t);
		int val = arr[i];
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					if (arr[i] & (1 << k))
						prv[j][k] = i;
				}
			}
		}
		for (int j = 0; j <= 19; j++) {
			if (arr[i] & (1 << j)) {
				for (int l = 0; l <= 19; ++l)
					dp[i][l] = min(dp[i][l], prv[j][l]);
			}
		}
	}
	for (int i = 0; i < q; ++i) {
		int a, b, temp = 1e9;
		scanf("%d %d", &a, &b);
		for (int j = 0; j <= 19; j++) {
			if (arr[b - 1] & (1 << j)) {
				temp = min(temp, dp[a - 1][j]);
			}
		}
		if (temp <= b - 1) {
			printf("Shi\n");
		}
		else printf("Fou\n");
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, q, arr[300010], dp[300010][20];
//dp[i][j] : i번 index에서부터 j번 bit가 켜지는 최소 index
// prv[i][j] : 현재 i번 비트를 가지고 있을때 j번 비트가 켜지는 최소 index
int prv[20][20];
int main() {
	memset(dp, 0x3f, sizeof dp);
	memset(prv, 0x3f, sizeof prv);
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					if (arr[i] & (1 << k))
						prv[j][k] = i;
				}
			}
		}
		for (int j = 0; j <= 19; j++) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					dp[i][k] = min(dp[i][k], prv[j][k]);
				}
			}
		}
		for (int j = 0; j <= 19; j++) {
			if (arr[i] & (1 << j)) {
				for (int k = 0; k <= 19; ++k) {
					prv[j][k] = min(dp[i][k], prv[j][k]);
				}
			}
		}
	}
	for (int i = 0; i < q; ++i) {
		int a, b, temp = 1e9;
		scanf("%d %d", &a, &b);
		for (int j = 0; j <= 19; j++) {
			if (arr[b - 1] & (1 << j)) {
				temp = min(temp, dp[a - 1][j]);
			}
		}
		if (temp <= b - 1) {
			printf("Shi\n");
		}
		else printf("Fou\n");
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, cnt, q, arr[300010], dp[300010];
int prv[20];
int main() {
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		int val = 0;
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= arr[i];
				val |= prv[j];
			}
		}
		dp[i] = val;
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (dp[a-1] & arr[b-1])printf("Shi\n");
		else printf("Fou\n");
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<memory.h>
#include<string>
#include<stack>
#include<math.h>
#include<queue>
#include<set>
#define mod 1000000007
#define mod2 16769023
#define fio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int GO_MAX = 26;
const int ESP = 1e-9;
int n, q, arr[300010], dp[300010][2];
int prv[20];
int main() {
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; ++i)
		scanf("%d", &arr[i]);
	for (int i = n - 1; i >= 0; --i) {
		int val = arr[i];
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= arr[i];
				val |= prv[j];
			}
		}
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= val;
			}
		}
		dp[i][0] = val;
	}
	for (int i = 0; i <= 19; i++)prv[i] = 0;
	for (int i = 0; i < n; ++i) {
		int val = arr[i];
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= arr[i];
				val |= prv[j];
			}
		}
		for (int j = 0; j <= 19; ++j) {
			if (arr[i] & (1 << j)) {
				prv[j] |= val;
			}
		}
		dp[i][1] = val;
	}
	for (int i = 0; i < q; ++i) {
		int a, b;
		scanf("%d %d", &a, &b);
		if ((dp[a-1][0] & arr[b-1]) &&(dp[b-1][1] & arr[a-1]))printf("Shi\n");
		else printf("Fou\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define int long long

signed main(){

	fast ;
	int n;
	cin>>n;
	int q;
	cin>>q;

	int a[n+1]{0};
	for(int i=0;i<n;i++){
		cin>>a[i+1];
	}

	int d[n+1][25]{0};
	int d1to1[25][25]{0};
	for(int i=0;i<25;i++){
		for(int j=0;j<25;j++){
			if(i!=j){
				d1to1[i][j]=INT_MAX;
			}
		}
	}

	for(int i=n-1;i>=0;i--){
		 	vector<int> zeros,ones;
		 	for(int j=0;j<25;j++){
		 		if((1<<j)&a[i]){
		 			d[i][j]=0;
		 			for(int k=0;k<25;k++){
						if((1<<k)&a[i]){
							d1to1[j][k]=0;
						}
		 			}
		 			ones.push_back(j);
		 		}
		 		else{
		 			zeros.push_back(j);
		 		}
		 	}
		 	for(int j:zeros){
		 		int mi=INT_MAX;
		 		for(int k:ones){
		 			mi=min(mi,d1to1[j][k]);
		 		}
		 		for(int k:ones){
		 			d1to1[j][k]=mi;
		 		}
		 		d[i][j]=mi;
		 	}
		 	for(int j=0;j<25;j++){
		 		for(int k=0;k<25;k++){
		 			if(j!=k)
		 				d1to1[j][k]++;
		 		}
		 	}
	}

	while(q--){
		int x,y;
		cin>>x>>y;
		y=a[y];
		bool flag=false;
		for(int i=0;i<25;i++){
			if(((1<<i)&y)==0)continue;
			if(d[x][i]<=(y-x)){
				flag=true;
				break;
			}
		}
		if(flag){
			cout<<"Shi"<<endl;
		}
		else{
			cout<<"Fou"<<endl;
		}
	}

}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map>
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll>
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 300010
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20

using namespace std;
typedef priority_queue<ll, vector<ll > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

ll n,q;
ll ar[ N ];
ll dist1to1[ 25 ][ 25 ];
ll mindist[ N ][ 25 ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin >> n >> q;
    for ( ll i =1; i <= n; i ++)
        cin >> ar[i];
    for ( ll i = 0; i <= 20; i ++)
        for ( ll j = 0; j <= 20 ; j ++)
            if ( i != j )
                dist1to1[i][j] = INT_MAX;
    for ( ll i = n; i >= 1; i --){
        vector < int > zeros, ones;
        for ( ll j = 0; j <= 20 ; j ++){
            if ( (1<<j)&ar[i] ){
                mindist[i][j] = 0;
                ones.pb(j);
                for ( ll k = 0; k <= 20; k ++)
                    if ( (1<<k)&ar[i] )
                        dist1to1[j][k] = 0;
            }
            else{
                zeros.pb(j);
            }
        }
        for ( auto it0 : zeros ){
            ll mi = INT_MAX;
            for ( auto it1 : ones )
                mi = min(mi,dist1to1[it1][it0]);
            for ( auto it1 : ones )
                dist1to1[it1][it0] = mi;
            mindist[i][it0] = mi;
        }
        for ( ll j = 0; j <= 20 ; j ++){
            for ( ll k = 0; k <= 20; k ++){
                if ( j != k )
                    dist1to1[j][k] ++;
            }
        }
    }
    while ( q-- ){
        ll x,y;
        cin >> x >> y;
        ll mi = INT_MAX;
        for ( ll j = 0; j <= 20; j ++){
            if ( ar[y]&(1<<j) ){
                mi = min(mi,mindist[x][j]);
            }
        }
        if ( mi <= y-x ){
            cout <<"Shi\n";
        }
        else{
            cout <<"Fou\n";
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define int long long

signed main(){

	fast ;
	int n;
	cin>>n;
	int q;
	cin>>q;

	int a[n+1]{0};
	for(int i=0;i<n;i++){
		cin>>a[i+1];
	}

	int d[n+1][25]{0};
	int d1to1[25][25]{0};
	for(int i=0;i<25;i++){
		for(int j=0;j<25;j++){
			if(i!=j){
				d1to1[i][j]=INT_MAX;
			}
		}
	}

	for(int i=n-1;i>=0;i--){
		 	vector<int> zeros,ones;
		 	for(int j=0;j<25;j++){
		 		if((1<<j)&a[i]){
		 			d[i][j]=0;
		 			for(int k=0;k<25;k++){
						if((1<<k)&a[i]){
							d1to1[j][k]=0;
						}
		 			}
		 			ones.push_back(j);
		 		}
		 		else{
		 			zeros.push_back(j);
		 		}
		 	}
		 	for(int j:zeros){
		 		int mi=-1e12;
		 		for(int k:ones){
		 			mi=min(mi,d1to1[j][k]);
		 		}
		 		for(int k:ones){
		 			d1to1[j][k]=mi;
		 		}
		 	}
		 	for(int j=0;j<25;j++){
		 		for(int k=0;k<25;k++){
		 			if(j!=k)
		 				d1to1[j][k]++;
		 		}
		 	}
	}

	while(q--){
		int x,y;
		cin>>x>>y;
		y=a[y];
		bool flag=false;
		for(int i=0;i<25;i++){
			if(((1<<i)&y)==0)continue;
			if(d[x][i]<=(y-x)){
				flag=true;
				break;
			}
		}
		if(flag){
			cout<<"Shi"<<endl;
		}
		else{
			cout<<"Fou"<<endl;
		}
	}

}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map>
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll li
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll>
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 300010
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20

// #define INTMAX 200000000

// using namespace boost;
// #define si short int

using namespace std;
typedef priority_queue<ll, vector<ll > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

ll n,q;
ll ar[ N ];
ll dist1to1[ 25 ][ 25 ];
ll mindist[ N ][ 25 ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin >> n >> q;
    for ( ll i =1; i <= n; i ++)
        cin >> ar[i];
    for ( ll i = 0; i <= 20; i ++)
        for ( ll j = 0; j <= 20 ; j ++)
            if ( i != j )
                dist1to1[i][j] = INT_MAX;
    for ( ll i = n; i >= 1; i --){
        vector < int > zeros, ones;
        for ( ll j = 0; j <= 20 ; j ++){
            if ( (1<<j)&ar[i] ){
                mindist[i][j] = 0;
                ones.pb(j);
                for ( ll k = 0; k <= 20; k ++)
                    if ( (1<<k)&ar[i] )
                        dist1to1[j][k] = 0;
            }
            else{
                zeros.pb(j);
            }
        }
        for ( auto it0 : zeros ){
            ll mi = INT_MAX;
            for ( auto it1 : ones )
                mi = min(mi,dist1to1[it1][it0]);
            for ( auto it1 : ones )
                dist1to1[it1][it0] = mi;
            // because we can jump from any set bit in the number to any other
            // set bit in the same number in 0 steps
            mindist[i][it0] = mi;
        }
        for ( ll j = 0; j <= 20 ; j ++){
            for ( ll k = 0; k <= 20; k ++){
                if ( j != k )
                    dist1to1[j][k] ++;
            }
        }
    }
    while ( q-- ){
        ll x,y;
        cin >> x >> y;
        ll mi = INT_MAX;
        for ( ll j = 0; j <= 20; j ++){
            if ( ar[y]&(1<<j) ){
                mi = min(mi,mindist[x][j]);
            }
        }
        if ( mi <= y-x ){
            cout <<"Shi\n";
        }
        else{
            cout <<"Fou\n";
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define int long long

signed main(){

	fast ;
	int n;
	cin>>n;
	int q;
	cin>>q;

	int a[n]{0};
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	int d[n][25]{0};
	int d1to1[25][25]{0};
	for(int i=0;i<25;i++){
		for(int j=0;j<25;j++){
			if(i!=j){
				d1to1[i][j]=INT_MAX;
			}
		}
	}

	for(int i=n-1;i>=0;i--){
		 	vector<int> zeros,ones;
		 	for(int j=0;j<25;j++){
		 		if((1<<j)&a[i]){
		 			d[i][j]=0;
		 			for(int k=0;k<25;k++){
						if((1<<k)&a[i]){
							d1to1[j][k]=0;
						}
		 			}
		 			ones.push_back(j);
		 		}
		 		else{
		 			zeros.push_back(j);
		 		}
		 	}
		 	for(int j:zeros){
		 		int mi=-1e12;
		 		for(int k:ones){
		 			mi=min(mi,d1to1[j][k]);
		 		}
		 		d[i][j]=mi;
		 	}
		 	for(int j=0;j<25;j++){
		 		for(int k=0;k<25;k++){
		 			if(j!=k)
		 				d1to1[j][k]++;
		 		}
		 	}
	}

	while(q--){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		y=a[y];
		bool flag=false;
		for(int i=0;i<25;i++){
			if(((1<<i)&y)==0)continue;
			if(d[x][i]<=(y-x)){
				flag=true;
				break;
			}
		}
		if(flag){
			cout<<"Shi"<<endl;
		}
		else{
			cout<<"Fou"<<endl;
		}
	}

}


#include <bits/stdc++.h>
#include <bits/basic_ios.h>

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1;
	// cin >> t;
	int tt = t;
	while (t--) {
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

int lst[25];
const int maxn = 3e5 + 55;
int arr[maxn];
bool ans[maxn] = {false};
int nxt[maxn][20];
const int inf = (int) 1e15;

void solve() {
	int n, q; cin >> n >> q;
	for (int i = 0; i < maxn; i += 1)
		for (int j = 0; j < 20; ++j)
			nxt[i][j] = inf;
	for (int i = 1; i <= n; i += 1)
		cin >> arr[i];
	for (int i = 0; i < 20; ++i)
		lst[i] = inf;
	for (int i = n; i >= 1; i -= 1) {
		for (int j = 0; j < 20; ++j) {
			if ((1LL << j) & arr[i]) {
				nxt[i][j] = lst[j];
				for (int k = 0; k < 20; ++k) {
					if (k == j) continue;
					if (lst[j] != inf) nxt[i][k] = min(nxt[i][k], nxt[lst[j]][k]);
				}
			}
		}
		for (int j = 0; j < 20; ++j) {
			if ((1LL << j) & arr[i])
				lst[j] = i;
		}
	}
	for (int i = 1; i <= q; i += 1) {
		int a, b; cin >> a >> b;
		bool ok = false;
		for (int j = 0; j < 20; ++j)
			if (nxt[a][j] <= b and ((1LL << j) & arr[b]))
				ok = true;
		if (ok) cout << "Shi";
		else cout << "Fou";
		cout << endl;
	}
}


#include <bits/stdc++.h>
#include <bits/basic_ios.h>

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1;
	// cin >> t;
	int tt = t;
	while (t--) {
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

int lst[25];
const int maxn = 3e5 + 55;
int arr[maxn];
bool ans[maxn] = {false};
int nxt[maxn][20];
const int inf = (int) 1e15;

void solve() {
	int n, q; cin >> n >> q;
	for (int i = 1; i <= n; i += 1)
		cin >> arr[i];
	for (int i = 0; i < 20; ++i)
		lst[i] = inf;
	for (int i = n; i >= 1; i -= 1) {
		for (int j = 0; j < 20; ++j)
			nxt[i][j] = lst[j];
		for (int j = 0; j < 20; ++j) {
			if ((1LL << j) & arr[i])
				lst[j] = i;
		}
	}
	for (int i = 1; i <= q; i += 1) {
		int a, b; cin >> a >> b;
		bool ok = false;
		for (int j = 0; j < 20; ++j)
			if (nxt[a][j] <= b and ((1LL << j) & arr[b]))
				ok = true;
		if (ok) cout << "Shi";
		else cout << "Fou";
		cout << endl;
	}
}


#include <bits/stdc++.h>
#include <bits/basic_ios.h>

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1;
	// cin >> t;
	int tt = t;
	while (t--) {
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

const int maxn = 3e5 + 55;
int lst[25];
int arr[maxn];
int pr[maxn], sz[maxn];

void make_set (int x) {
	pr[x] = x;
	sz[x] = 1;
}

int find (int a) {
	if (pr[a] == a) return a;
	else return pr[a] = find(pr[a]);
}

void merge (int a, int b) {
	a = find(a), b = find(b);
	if (a == b)
		return;
	if (sz[a] < sz[b]) swap(a, b);
	pr[b] = a;
	sz[a] += sz[b];
}

vector<pair<int, int>> queries[maxn];
bool ans[maxn] = {false};

void solve() {
	int n, q; cin >> n >> q;
	for (int i = 1; i <= n; i += 1)
		cin >> arr[i];
	for (int i = 0; i < 20; ++i) lst[i] = -1;
	for (int i = 1; i <= q; i += 1) {
		int a, b; cin >> a >> b;
		queries[b].push_back({a, i});
	}
	for (int r = 1; r <= n; r += 1) {
		make_set(r);
		for (int bit = 0; bit < 20; ++bit) {
			if (!((1LL << bit) & arr[r])) continue;
			for (auto lol: queries[r]) {
				if (lst[bit] < lol.first)
					continue;
				if (find(lst[bit]) == find(lol.first)) {
					ans[lol.second] = true;
				}
			}
		}
		for (int bit = 0; bit < 20; ++bit) {
			if ((1LL << bit) & arr[r]) {
				if (lst[bit] != -1) merge(lst[bit], r);
				lst[bit] = r;
			}
		}
	}
	for (int i = 1; i <= q; i += 1) {
		if (ans[i]) cout << "Shi";
		else cout << "Fou";
		cout << endl;
	}
}


#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=300010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int a[maxn];
int dp[maxn][25];
int b[25][25];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=20;i++)
    {
        for(int j=0;j<=20;j++)
        {
            b[i][j]=n+1;
        }
    }
    memset(dp,inf,sizeof(dp));
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                for(int k=0;k<=20;k++)
                {
                    if((a[i]&(1<<k)))
                    {
                        b[j][k]=i;
                    }
                    dp[i][k]=min(b[j][k],dp[i][k]);
                }
            }
        }
    }
    int x,y;
    int f=0;
    while(m--)
    {
        scanf("%d%d",&x,&y);
        f=0;
        for(int j=0;j<=20;j++)
        {
            if(a[y]&(1<<j))
            {
                if(dp[x][j]<=y)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f)
            printf("Shi\n");
        else
            printf("Fou\n");
    }

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=300010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int a[maxn];
int dp[maxn][25];
int b[25];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=20;i++)
    {
        b[i]=inf;
    }
    memset(dp,inf,sizeof(dp));
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                dp[i][j]=i;
                if(b[j]<=n)
                {
                    for(int k=0;k<=20;k++)
                        dp[i][k]=min(dp[i][k],dp[b[j]][k]);
                }
                b[j]=i;
            }
        }
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=0;j<=20;j++)
//        {
//            cout<<dp[i][j]<<' ';
//        }
//        cout<<endl;
//    }
    int x,y;
    int f=0;
    while(m--)
    {
        scanf("%d%d",&x,&y);
        f=0;
        for(int j=0;j<=20;j++)
        {
            if(a[y]&(1<<j))
            {
                if(dp[x][j]<=y)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f)
            printf("Shi\n");
        else
            printf("Fou\n");
    }

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=300010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int a[maxn];
int dp[maxn][25];
int b[25][25];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=20;i++)
    {
        for(int j=0;j<=20;j++)
        {
            b[i][j]=n+1;
        }
    }
    memset(dp,inf,sizeof(dp));
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                for(int k=0;k<=20;k++)
                {
                    if((a[i]&(1<<k)))
                    {
                        b[j][k]=i;
                    }
                    dp[i][k]=min(b[j][k],dp[i][k]);
                }
            }
        }
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                for(int k=0;k<=20;k++)
                {
                    b[j][k]=min(b[j][k],dp[i][k]);
                }
            }
        }
    }
    int x,y;
    int f=0;
    while(m--)
    {
        scanf("%d%d",&x,&y);
        f=0;
        for(int j=0;j<=20;j++)
        {
            if(a[y]&(1<<j))
            {
                if(dp[x][j]<=y)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f)
            printf("Shi\n");
        else
            printf("Fou\n");
    }

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=300010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int a[maxn];
int dp[maxn][25];
int b[25][25];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=20;i++)
    {
        for(int j=0;j<=20;j++)
        {
            b[i][j]=n+1;
        }
    }
    memset(dp,inf,sizeof(dp));
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                dp[i][j]=i;
                for(int k=0;k<=20;k++)
                {
                    if((a[i]&(1<<k)))
                    {
                        b[j][k]=i;
                    }
                    dp[i][k]=min(b[j][k],dp[i][k]);
                }
            }
        }
    }
    int x,y;
    int f=0;
    while(m--)
    {
        scanf("%d%d",&x,&y);
        f=0;
        for(int j=0;j<=20;j++)
        {
            if(a[y]&(1<<j))
            {
                if(dp[x][j]<=y)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f)
            printf("Shi\n");
        else
            printf("Fou\n");
    }

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
//#include<unordered_map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'1')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
//const double pi=acos(-1);
const int maxn=300010;
//const ll Mod=1000000007;
const ll Mod=998244353;

int a[maxn];
int dp[maxn][25];
int b[25];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=20;i++)
    {
        b[i]=inf;
    }
    memset(dp,inf,sizeof(dp));
    for(int i=n;i>=1;i--)
    {
        for(int j=0;j<=20;j++)
        {
            if((a[i]&(1<<j)))
            {
                dp[i][j]=i;
                if(b[j]<=n)
                {
                    for(int k=0;k<=20;k++)
                        dp[i][k]=dp[b[j]][k];
                }
                b[j]=i;
            }
        }
    }
//    for(int i=1;i<=n;i++)
//    {
//        for(int j=0;j<=20;j++)
//        {
//            cout<<dp[i][j]<<' ';
//        }
//        cout<<endl;
//    }
    int x,y;
    int f=0;
    while(m--)
    {
        scanf("%d%d",&x,&y);
        f=0;
        for(int j=0;j<=20;j++)
        {
            if(a[y]&(1<<j))
            {
                if(dp[x][j]<=y)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f)
            printf("Shi\n");
        else
            printf("Fou\n");
    }

    return 0;
}


#include <iostream>

using namespace std;

int n, q, x, y;

int v[300005], lst[20];
int nxt[300005][20];

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> q;
  for(int i = 1; i <= n; i++)
    cin >> v[i];
  for(int i = n; i >= 1; i--) {
    for(int j = 0; j < 19; j++)
      nxt[i][j] = n + 1;
    for(int j = 18; j >= 0; j--) {
      if(v[i] & (1 << j)) {
        for(int k = 0; k < 19; k++)
          nxt[i][k] = min(nxt[i][k], nxt[lst[j]][k]);
        nxt[i][j] = lst[j] = i;
      }
    }
  }
  for(; q; q--) {
    cin >> x >> y;
    bool ok = 0;
    for(int i = 0; i < 19; i++) {
      if((v[y] & (1 << i)) && nxt[x][i] <= y)
        ok = 1;
    }
    cout << (ok == 1 ? "Shi\n" : "Fou\n");
  }
  return 0;
}


#include <iostream>

using namespace std;

int n, q, x, y;

int v[300005], lst[20];
int nxt[300005][20];

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> q;
  for(int i = 1; i <= n; i++)
    cin >> v[i];
  for(int i = n; i >= 1; i--) {
    for(int j = 18; j >= 0; j--) {
      if(v[i] & (1 << j))
        lst[j] = i;
      nxt[i][j] = lst[j];
    }
  }
  for(; q; q--) {
    cin >> x >> y;
    bool ok = 0;
    for(int i = 0; i < 19; i++) {
      if((v[y] & (1 << i)) && nxt[x][i] <= y)
        ok = 1;
    }
    cout << (ok == 1 ? "Shi\n" : "Fou\n");
  }
  return 0;
}


#include <iostream>

using namespace std;

int n, q, x, y;

int v[300005], lst[20];
int nxt[300005][20];

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> q;
  for(int i = 1; i <= n; i++)
    cin >> v[i];
  for(int i = n; i >= 1; i--) {
    for(int j = 18; j >= 0; j--) {
      if(v[i] & (1 << j)) {
        for(int k = 0; k < 19; k++)
          nxt[i][k] = min(nxt[i][k], nxt[lst[j]][k]);
        nxt[i][j] = lst[j] = i;
      }
    }
  }
  for(; q; q--) {
    cin >> x >> y;
    bool ok = 0;
    for(int i = 0; i < 19; i++) {
      if((v[y] & (1 << i)) && nxt[x][i] <= y)
        ok = 1;
    }
    cout << (ok == 1 ? "Shi\n" : "Fou\n");
  }
  return 0;
}


#include <iostream>

using namespace std;

int n, q, x, y;

int v[300005], lst[20];
int nxt[300005][20];

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> q;
  for(int i = 1; i <= n; i++)
    cin >> v[i];
  for(int j = 0; j < 19; j++)
    lst[j] = n + 1, nxt[n + 1][j] = n + 1;
  for(int i = n; i >= 1; i--) {
    for(int j = 0; j < 19; j++)
      nxt[i][j] = n + 1;
    for(int j = 18; j >= 0; j--) {
      if(v[i] & (1 << j)) {
        for(int k = 0; k < 19; k++)
          nxt[i][k] = min(nxt[i][k], nxt[lst[j]][k]);
        nxt[i][j] = lst[j] = i;
      }
    }
  }
  for(; q; q--) {
    cin >> x >> y;
    bool ok = 0;
    for(int i = 0; i < 19; i++) {
      if((v[y] & (1 << i)) && nxt[x][i] <= y)
        ok = 1;
    }
    cout << (ok == 1 ? "Shi\n" : "Fou\n");
  }
  return 0;
}


//#pragma GCC optimize "trapv"
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define int ll
const int M = 1000000007;
#define pb push_back
#define fs first
#define sc second
#define forn(i,k,n) for(int i = k; i < n; ++i)
#define nfor(i,n,k) for(int i = n; i >= k; --i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vvpii vector<vector<pait<int,int>>>
#define all(arr) arr.begin(), arr.end()
#define endl '\n'
#define dbgarr(V,n) forn(i,0,n) cout << V[i] << " "; cout << endl;
#define dbgarrrev(V,n) nfor(i,n,0) cout << V[i] << " "; cout << endl;
#define dbgmaze(V) for(auto x: V) {for(auto y : x) cout << y <<  " ";cout << endl;}
#define dbg2d(V,n,m) forn(i,0,n) {forn(j,0,m) cout << V[i][j] <<  " ";cout << endl;}
#define watch(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
const int N = 300005;
const int B = 20;
int a[N], go[N][B], last[B];
const int inf = 1000000000;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, q;
    cin >> n >> q;
    forn(i,0,n) cin >> a[i];
	forn(i,0,B) {
		last[i] = n;
		go[n][i] = n;
	}
	nfor(i,n - 1,0){
		forn(k,0,B) go[i][k] = n;
		forn(j,0,B){
			if((a[i] >> j) & 1){
				forn(k,0,B){
					go[i][k] = min(go[i][k], go[last[j]][k]);
				}
				last[j] = i;
				go[i][j] = i;
			}
		}
	}
	forn(i,0,q){
		int x, y; cin >> x >> y;
		x--; y--;
		bool ok = false;
		forn(i,0,B){
			ok |= (((a[y] >> i) & 1) && go[x][i] <= y);
		}
		cout << (ok ? "Shi" : "Fou") << endl;
	}
    return 0;
}


//#pragma GCC optimize "trapv"
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//#define int ll
const int M = 1000000007;
#define pb push_back
#define fs first
#define sc second
#define forn(i,k,n) for(int i = k; i < n; ++i)
#define nfor(i,n,k) for(int i = n; i >= k; --i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vvpii vector<vector<pait<int,int>>>
#define all(arr) arr.begin(), arr.end()
#define endl '\n'
#define dbgarr(V,n) forn(i,0,n) cout << V[i] << " "; cout << endl;
#define dbgarrrev(V,n) nfor(i,n,0) cout << V[i] << " "; cout << endl;
#define dbgmaze(V) for(auto x: V) {for(auto y : x) cout << y <<  " ";cout << endl;}
#define dbg2d(V,n,m) forn(i,0,n) {forn(j,0,m) cout << V[i][j] <<  " ";cout << endl;}
#define watch(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
const int N = 300005;
const int B = 20;
int a[N], go[N][B], last[B];
const int inf = 1000000000;
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, q;
    cin >> n >> q;
    forn(i,0,n) cin >> a[i];
//	forn(i,0,B) {
//		last[i] = n;
//		go[n][i] = n;
//	}
//	nfor(i,n - 1,0){
//		forn(k,0,B) go[i][k] = n;
//		forn(j,0,B){
//			if((a[i] >> j) & 1){
//				forn(k,0,B){
//					go[i][k] = min(go[i][k], go[last[j]][k]);
//				}
//				last[j] = i;
//				go[i][j] = i;
//			}
//		}
//	}
	memset(go,-1,sizeof go);
//	forn(i,0,B) {
//		last[i] = -1;
//		go[n][i] = -1;
//	}
	forn(i,0,n){
		forn(k,0,B) go[i][k] = -1;
		forn(j,0,B){
			if((a[i] >> j) & 1){
				forn(k,0,B){
					if(last[j] > 0)
					go[i][k] = max(go[i][k], go[last[j]][k]);
				}
				last[j] = i;
				go[i][j] = i;
			}
		}
	}
	//dbg2d(go,n,10);
	forn(i,0,q){
		int x, y; cin >> x >> y;
		x--; y--;
		bool ok = false;
		if(!a[x] || !a[y]){
			cout << "Fou\n";
			continue;
		}
		forn(i,0,B){
			ok |= (go[y][i] >= x);
		}
		cout << (ok ? "Shi" : "Fou") << endl;
	}
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds;
using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define true false
#define false true
#define ull unsigned long long0
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)(a.size())
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll int
#define lb lower_bound
#define f first
#define s second
#define endl "\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = (int)1e9 + 100;
const ll INF = (ll)2e18;
const int mod = 1e9+7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
ll bp (ll a, ll n) {
    ll res = 1;
    while (n) {
       if (n & 1)
           res *= a,res%=mod;
        a *= a,a%=mod;
        n >>= 1;
    }
    return res%mod;
}

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
   return a;
}

ll n,m,t,x,y,z,x1,y1,x2,y2,maxx=0,k,minn=inf,cnt,R,cnt2,cx,cy,sum,pos,q;
ll a[300300],r[300300][20],ans[300300][20];
vi s[22];
bool b[300300];
void go(int n){
    b[n]=true;
    for(int k=0;k<19;k++){
        if(!((1<<k)&a[n]))continue;
        ans[n][k]=n;
        if(!b[r[n][k]]){
            go(r[n][k]);
        }
        for(ll i=0;i<19;i++){
            ans[n][i]=min(ans[n][i],ans[r[n][k]][i]);
        }
    }
}

int main(){
    scanf("%d%d",&n,&q);
    for(ll i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(ll j=0;j<19;j++){
            if((1<<j)&a[i])s[j].pb(i);
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<19;j++)ans[i][j]=300001;
    }
    for(int i=0;i<19;i++){
        ll prev=0;
        for(auto k:s[i]){
            if(prev)r[prev][i]=k;
            prev=k;
        }
    }
    b[0]=1;
    for(ll i=1;i<=n;i++){
        if(!b[i])go(i);
    }
    for(ll i=0;i<q;i++){
        cin>>x>>y;
        bool ok=0;
        for(int k=0;k<19;k++){
                if(!((1<<k)&a[y]))continue;
            if(ans[x][k]<=y){
                printf("Shi\n");
                ok=1;
                break;
            }
        }
        if(!ok)printf("Fou\n");
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds;
using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define true false
#define false true
#define ull unsigned long long0
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)(a.size())
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll int
#define lb lower_bound
#define f first
#define s second
#define endl "\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = (int)1e9 + 100;
const ll INF = (ll)2e18;
const int mod = 1e9+7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
ll bp (ll a, ll n) {
    ll res = 1;
    while (n) {
       if (n & 1)
           res *= a,res%=mod;
        a *= a,a%=mod;
        n >>= 1;
    }
    return res%mod;
}

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
   return a;
}

ll n,m,t,x,y,z,x1,y1,x2,y2,maxx=0,k,minn=inf,cnt,R,cnt2,cx,cy,sum,pos,q;
ll a[300300],r[300300][20],ans[300300][20];
set<int> s[22];
bool b[300300];
void go(int n){
    b[n]=true;
    for(int k=0;k<19;k++){
        if(!((1<<k)&a[n]))continue;
        ans[n][k]=n;
        if(!b[r[n][k]]){
            go(r[n][k]);
        }
        for(ll i=0;i<19;i++){
            ans[n][i]=min(ans[n][i],ans[r[n][k]][i]);
        }
    }
}

int main(){
    scanf("%d%d",&n,&q);
    for(ll i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(ll j=0;j<19;j++){
            if((1<<j)&a[i])s[j].insert(i);
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<19;j++)ans[i][j]=300001;
    }
    for(ll i=1;i<=n;i++){
        for(int k=0;k<19;k++){
                if(!((1<<k)&a[i]))continue;
            set<int>:: iterator it=s[k].upper_bound(i);
            if(it!=s[k].end()){
                r[i][k]=(*it);
            }
        }
    }
    b[0]=1;
    for(ll i=1;i<=n;i++){
        if(!b[i])go(i);
    }
    for(ll i=0;i<q;i++){
        cin>>x>>y;
        bool ok=0;
        for(int k=0;k<19;k++){
                if(!((1<<k)&a[y]))continue;
            if(ans[x][k]<=y){
                printf("Shi\n");
                ok=1;
                break;
            }
        }
        if(!ok)printf("Fou\n");
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds;
using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define true false
#define false true
#define ull unsigned long long0
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)(a.size())
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll int
#define lb lower_bound
#define f first
#define s second
#define endl "\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = (int)1e9 + 100;
const ll INF = (ll)2e18;
const int mod = 1e9+7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
ll bp (ll a, ll n) {
    ll res = 1;
    while (n) {
       if (n & 1)
           res *= a,res%=mod;
        a *= a,a%=mod;
        n >>= 1;
    }
    return res%mod;
}

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
   return a;
}

ll n,m,t,x,y,z,x1,y1,x2,y2,maxx=0,k,minn=inf,cnt,R,cnt2,cx,cy,sum,pos,q;
ll a[300300],r[300300][20],ans[300300][20];
set<int> s[22];
bool b[300300];
void go(int n){
    b[n]=true;
    for(int k=0;k<19;k++){
        if(!((1<<k)&a[n]))continue;
        ans[n][k]=n;
        if(!b[r[n][k]]){
            go(r[n][k]);
        }
        for(ll i=0;i<19;i++){
            ans[n][i]=min(ans[n][i],ans[r[n][k]][i]);
        }
    }
}

int main(){
    scanf("%d%d",&n,&q);
    for(ll i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(ll j=0;j<19;j++){
            if((1<<j)&a[i])s[j].insert(i);
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<19;j++)ans[i][j]=300001;
    }
    for(int i=0;i<19;i++){
        ll prev=0;
        for(auto k:s[i]){
            if(prev)r[prev][i]=k;
            prev=k;
        }
    }
    b[0]=1;
    for(ll i=1;i<=n;i++){
        if(!b[i])go(i);
    }
    for(ll i=0;i<q;i++){
        cin>>x>>y;
        bool ok=0;
        for(int k=0;k<19;k++){
                if(!((1<<k)&a[y]))continue;
            if(ans[x][k]<=y){
                printf("Shi\n");
                ok=1;
                break;
            }
        }
        if(!ok)printf("Fou\n");
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds;
using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define true false
#define false true
#define ull unsigned long long0
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)(a.size())
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll int
#define lb lower_bound
#define f first
#define s second
#define endl "\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = (int)1e9 + 100;
const ll INF = (ll)2e18;
const int mod = 1e9+7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
ll bp (ll a, ll n) {
    ll res = 1;
    while (n) {
       if (n & 1)
           res *= a,res%=mod;
        a *= a,a%=mod;
        n >>= 1;
    }
    return res%mod;
}

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
   return a;
}

ll n,m,t,x,y,z,x1,y1,x2,y2,maxx=0,k,minn=inf,cnt,R,cnt2,cx,cy,sum,pos,q;
ll a[300300],r[300300][20],ans[300300][20];
set<int> s[22];
bool b[300300];
void go(int n){
    b[n]=true;
    for(int k=0;k<19;k++){
        if(!(1<<k)&a[n])continue;
        ans[n][k]=n;
        if(!b[r[n][k]]){
            go(r[n][k]);
        }
        for(ll i=0;i<19;i++){
            ans[n][i]=min(ans[n][i],ans[r[n][k]][i]);
        }
    }
}

int main(){
    scanf("%d%d",&n,&q);
    for(ll i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(ll j=0;j<19;j++){
            if((1<<j)&a[i])s[j].insert(i);
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<19;j++)ans[i][j]=300001;
    }
    for(ll i=1;i<=n;i++){
        for(int k=0;k<19;k++){
                if(!(1<<k)&a[i])continue;
            set<int>:: iterator it=s[k].upper_bound(i);
            if(it!=s[k].end()){
                r[i][k]=(*it);
            }
        }
    }
    b[0]=1;
    for(ll i=1;i<=n;i++){
        if(!b[i])go(i);
    }
    for(ll i=0;i<q;i++){
        cin>>x>>y;
        bool ok=0;
        for(int k=0;k<19;k++){
                if(!(1<<k&a[y]))continue;
            if(ans[x][k]<=y){
                printf("Shi\n");
                ok=1;
                break;
            }
        }
        if(!ok)printf("Fou\n");
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace __gnu_pbds;
using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define true false
#define false true
#define ull unsigned long long0
#define vll vector <long long>
#define pii pair < int, int >
#define sz(a) (int)(a.size())
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll int
#define lb lower_bound
#define f first
#define s second
#define endl "\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = (int)1e9 + 100;
const ll INF = (ll)2e18;
const int mod = 1e9+7;
const double eps = 1e-9;
const int MaxN = 2e5 + 1;
const double pi = acos(-1.0);
ll bp (ll a, ll n) {
    ll res = 1;
    while (n) {
       if (n & 1)
           res *= a,res%=mod;
        a *= a,a%=mod;
        n >>= 1;
    }
    return res%mod;
}

ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
   return a;
}

ll n,m,t,x,y,z,x1,y1,x2,y2,maxx=0,k,minn=inf,cnt,R,cnt2,cx,cy,sum,pos,q;
ll a[300300],r[300300][20],ans[300300][20];
vi v[300300];
set<int> s[22];
bool b[300300];
void go(int n){
    b[n]=true;
    for(auto k:v[n]){
        ans[n][k]=n;
        if(!b[r[n][k]]){
            go(r[n][k]);
        }
        for(ll i=0;i<19;i++){
            ans[n][i]=min(ans[n][i],ans[r[n][k]][i]);
        }
    }
}

int main(){
    scanf("%d%d",&n,&q);
    for(ll i=1;i<=n;i++){
        scanf("%d",&a[i]);
        for(ll j=0;j<19;j++){
            if((1<<j)&a[i])s[j].insert(i),v[i].pb(j);
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<19;j++)ans[i][j]=300001;
    }
    for(ll i=1;i<=n;i++){
        for(auto k:v[i]){
            set<int>:: iterator it=s[k].upper_bound(i);
            if(it!=s[k].end()){
                r[i][k]=(*it);
            }
        }
    }
    b[0]=1;
    for(ll i=1;i<=n;i++){
        if(!b[i])go(i);
    }
    for(ll i=0;i<q;i++){
        cin>>x>>y;
        bool ok=0;
        for(auto k:v[y]){
            if(ans[x][k]<=y){
                printf("Shi\n");
                ok=1;
                break;
            }
        }
        if(!ok)printf("Fou\n");
    }
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    int a,k, B=19; cin>>a>>k;
    vec<int> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    vec<vec<int>> dp(a, vec<int>(k, 1e6));
    vec<int> last(B, 1e6);
    for(int q=a-1; q>=0; q--){
        for(int w=0; w<B; w++){
            if(((m[q]>>w)&1)==0) continue;
            for(int e=0; e<B; e++) if(last[w]!=1e6) dp[q][e] = min(dp[q][e], dp[last[w]][e]);
            dp[q][w] = last[w] = q;
        }
    }
    for(; k; k--){
        int x,y, o=0; cin>>x>>y; x--; y--;
        for(int q=0; q<B; q++) o |= (m[y]>>q&1) && dp[x][q]<=y;
        if(o) cout<<"Shi"<<endl;
        else cout<<"Fou"<<endl;
    }
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    int a,k, B=19; cin>>a>>k;
    vec<int> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    vec<vec<int>> dp(a, vec<int>(B, 1e6));
    vec<int> last(B, 1e6);
    for(int q=a-1; q>=0; q--){
        for(int w=0; w<B; w++){
            if(((m[q]>>w)&1)==0) continue;
            for(int e=0; e<B; e++) if(last[w]!=1e6) dp[q][e] = min(dp[q][e], dp[last[w]][e]);
            dp[q][w] = last[w] = q;
        }
    }
    for(; k; k--){
        int x,y, o=0; cin>>x>>y; x--; y--;
        for(int q=0; q<B; q++) o |= (m[y]>>q&1) && dp[x][q]<=y;
        if(o) cout<<"Shi"<<endl;
        else cout<<"Fou"<<endl;
    }
}


#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<double, double>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);

int main() {
    fast;

}


#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int> >
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}

void solve()
{
	int n,q;
	cin>>n>>q;
	int a[n];
	loop(i,0,n)
	cin>>a[i];
	int dp[n][20],dp2[n][20];
	mem(dp,-1);mem(dp2,-1);
	loop(i,0,20)
	{
		if(a[0]&1<<i)
		{
			dp[0][i]=0;
			dp2[0][i]=0;
		}
	}
	loop(i,1,n)
	{
		loop(j,0,20)
		{
			if(a[i]&1<<j)
			dp[i][j]=i;
		}
		loop(j,0,20)
		{
			if(dp[i][j]!=i)
			{
				loop(k,0,20)
				{
					if(dp[i][k]==i&&dp2[i-1][k]!=-1)
					dp[i][j]=max(dp[i][j],dp[dp2[i-1][k]][j]);
				}
			}
		}
		loop(j,0,20)
		{
			dp2[i][j]=a[i]&1<<j?i:dp2[i-1][j];
		}
	}
	int x,y;
	bool flag;
	while(q--)
	{
		cin>>x>>y;
		y--,x--;
		flag=0;
		loop(i,0,20)
		{
			if(a[x]&(1<<i)&&dp[y][i]>=x)
			{
				flag=1;
				break;
			}
		}
		if(flag)
		cout<<"Shi\n";
		else
		cout<<"Fou\n";
	}
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int> >
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}

void solve()
{
	int n,q;
	cin>>n>>q;
	int a[n];
	loop(i,0,n)
	cin>>a[i];
	int dp[n][19];
	map<ii,int> dp2[n];
	loop(i,0,19)
	{
		loop(j,i+1,19)
		{
			if(a[0]&(1<<i)&&a[0]&(1<<j))
			dp2[0][mp(i,j)]=0;
			else
			dp2[0][mp(i,j)]=-1;
		}
	}
	loop(i,1,n)
	{
		loop(j,0,19)
		{
			loop(k,j+1,19)
			{
				if(a[i]&(1<<j)&&a[i]&(1<<k))
				dp2[i][mp(j,k)]=i;
				else
				dp2[i][mp(j,k)]=dp2[i-1][mp(j,k)];
			}
		}
	}
	/*loop(i,0,n)
	{
		loop(j,0,2)
		{
			loop(k,j+1,2)
			{
				cout<<dp2[i][mp(j,k)]<<" ";
			}
		}
		cout<<"\n";
	}*/
	//return;
	set<ii,greater<ii> > s;
	mem(dp,-1);
	loop(i,0,n)
	{
		loop(j,0,19)
		{
			if((a[i]&(1<<j))!=0)
			{
				dp[i][j]=i;
				s.insert(mp(i,j));
			}
		}
		//cout<<s.size()<<" ";
		auto it=s.begin();
		while(it!=s.end())
		{
			loop(j,0,19)
			{
				if(j==it->sd)
				continue;
				int z1=min(it->sd,j),z2=max(it->sd,j);
				if(dp2[it->ft][mp(z1,z2)]>dp[i][j])
				{
					if(dp[i][j]!=-1)
					s.erase(mp(dp[i][j],j));
					dp[i][j]=dp2[it->ft][mp(z1,z2)];
					s.insert(mp(dp[i][j],j));
				}
			}
			it=s.erase(it);
		}
		//cout<<s.size()<<"\n";
	}
	int x,y;
	bool flag;
	while(q--)
	{
		cin>>x>>y;
		y--,x--;
		flag=0;
		loop(i,0,19)
		{
			if(a[x]&(1<<i)&&dp[y][i]>=x)
			{
				flag=1;
				break;
			}
		}
		if(flag)
		cout<<"Shi\n";
		else
		cout<<"Fou\n";
	}
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int> >
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}

void solve()
{
	int n,q;
	cin>>n>>q;
	int a[n];
	loop(i,0,n)
	cin>>a[i];
	int dp[n][20];
	map<ii,int> dp2[n];
	bool b[n][20];
	loop(i,0,n)
	{
		int temp=a[i];
		loop(j,0,20)
		{
			b[i][j]=temp&1;
			temp>>=1;
		}
	}
	loop(i,0,20)
	{
		loop(j,i+1,20)
		{
			if(b[0][i]&b[0][j])
			dp2[0][mp(i,j)]=0;
			else
			dp2[0][mp(i,j)]=-1;
		}
	}
	loop(i,1,n)
	{
		loop(j,0,20)
		{
			loop(k,j+1,20)
			{
				if(b[i][j]&b[i][k])
				dp2[i][mp(j,k)]=i;
				else
				dp2[i][mp(j,k)]=dp2[i-1][mp(j,k)];
			}
		}
	}
	/*loop(i,0,n)
	{
		loop(j,0,2)
		{
			loop(k,0,2)
			{
				cout<<dp2[i][j][k]<<" ";
			}
		}
		cout<<"\n";
	}*/
	//return;
	set<ii,greater<ii> > s;
	mem(dp,-1);
	loop(i,0,n)
	{
		loop(j,0,20)
		{
			if(b[i][j])
			{
				dp[i][j]=i;
				s.insert(mp(i,j));
			}
		}
		auto it=s.begin();
		while(it!=s.end())
		{
			loop(j,0,20)
			{
				if(j==it->sd)
				continue;
				int z1=min(it->sd,j),z2=max(it->sd,j);
				if(dp2[it->ft][mp(z1,z2)]>dp[i][j])
				{
					if(dp[i][j]!=-1)
					s.erase(mp(dp[i][j],j));
					dp[i][j]=dp2[it->ft][mp(z1,z2)];
					s.insert(mp(dp[i][j],j));
				}
			}
			it=s.erase(it);
		}
	}
	int x,y;
	bool flag;
	while(q--)
	{
		cin>>x>>y;
		y--,x--;
		flag=0;
		loop(i,0,20)
		{
			if(b[x][i]&&dp[y][i]>=x)
			{
				flag=1;
				break;
			}
		}
		if(flag)
		cout<<"Shi\n";
		else
		cout<<"Fou\n";
	}
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int> >
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}

void solve()
{
	int n,q;
	cin>>n>>q;
	int a[n];
	loop(i,0,n)
	cin>>a[i];
	int dp[n][20],dp2[n][20][20];
	mem(dp2,-1);
	bool b[n][20];
	loop(i,0,n)
	{
		int temp=a[i];
		loop(j,0,20)
		{
			b[i][j]=temp&1;
			temp>>=1;
		}
	}
	loop(i,0,20)
	{
		loop(j,0,20)
		dp2[0][i][j]=b[0][i]&b[0][j]?0:-1;
	}
	loop(i,1,n)
	{
		loop(j,0,20)
		{
			loop(k,0,20)
			{
				dp2[i][j][k]=b[i][j]&b[i][k]?i:dp2[i-1][j][k];
			}
		}
	}
	/*loop(i,0,n)
	{
		loop(j,0,2)
		{
			loop(k,0,2)
			{
				cout<<dp2[i][j][k]<<" ";
			}
		}
		cout<<"\n";
	}*/
	//return;
	set<ii,greater<ii> > s;
	mem(dp,-1);
	loop(i,0,n)
	{
		loop(j,0,20)
		{
			if(b[i][j])
			{
				dp[i][j]=i;
				s.insert(mp(i,j));
			}
		}
		auto it=s.begin();
		while(it!=s.end())
		{
			loop(j,0,20)
			{
				if(dp2[it->ft][it->sd][j]>dp[i][j])
				{
					if(dp[i][j]!=-1)
					s.erase(mp(dp[i][j],j));
					dp[i][j]=dp2[it->ft][it->sd][j];
					s.insert(mp(dp[i][j],j));
				}
			}
			it=s.erase(it);
		}
	}
	int x,y;
	bool flag;
	while(q--)
	{
		cin>>x>>y;
		y--,x--;
		flag=0;
		loop(i,0,20)
		{
			if(b[x][i]&&dp[y][i]>=x)
			{
				flag=1;
				break;
			}
		}
		if(flag)
		cout<<"Shi\n";
		else
		cout<<"Fou\n";
	}
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);

#pragma warning(disable : 6031)
#pragma warning(disable : 4101)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);

// Solution

const int MAXN = 300005;

int n, q, x, y, A[MAXN], Z[MAXN][20], DP[MAXN][20];

void eval() {
    for (int k = 0; k < 20; k++) {
        Z[n - 1][k] = n;
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            Z[i][k] = Z[i + 1][k];

            if ((A[i + 1] >> k) & 1) {
                Z[i][k] = i + 1;
            }
        }
    }

    for (int k = 0; k < 20; k++) {
        DP[n - 1][k] = n;

        if ((A[n - 1] >> k) & 1) {
            DP[n - 1][k] = n - 1;
        }
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            DP[i][k] = n;

            if ((A[i] >> k) & 1) {
                DP[i][k] = i;
                continue;
            }

            for (int s = 0; s < 20; s++) {
                if (((A[i] >> s) & 1) && Z[i][s] < n) {
                    DP[i][k] = min(DP[i][k], DP[Z[i][s]][k]);
                }
            }
        }
    }
}

bool is_reachable(int x, int y) {
    for (int k = 0; k < 20; k++) {
        if (((A[y] >> k) & 1) && DP[x][k] <= y) {
            return true;
        }
    }

    return false;
}

int main() {
    scanf("%d%d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    eval();

    while (q--) {
        scanf("%d%d", &x, &y);
        x--;
        y--;

        if (is_reachable(x, y)) {
            printf("Shi\n");
        } else {
            printf("Fou\n");
        }
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);

#pragma warning(disable : 6031)
#pragma warning(disable : 4101)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);

// Solution

const int MAXN = 300005;

int n, q, x, y, A[MAXN], Z[MAXN][20], DP[MAXN][20];

void eval() {
    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            Z[i][k] = Z[i + 1][k];

            if ((A[i + 1] >> k) & 1) {
                Z[i][k] = i + 1;
            }
        }
    }

    for (int k = 0; k < 20; k++) {
        DP[n - 1][k] = n;

        if ((A[n - 1] >> k) & 1) {
            DP[n - 1][k] = n - 1;
        }
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            DP[i][k] = n;

            for (int s = 0; s < 20; s++) {
                if (((A[i] >> s) & 1) && Z[i][s] < n) {
                    DP[i][k] = min(DP[i][k], DP[Z[i][s]][k]);
                }
            }
        }
    }
}

bool is_reachable(int x, int y) {
    for (int k = 0; k < 20; k++) {
        if (((A[y] >> k) & 1) && DP[x][k] <= y) {
            return true;
        }
    }

    return false;
}

int main() {
    scanf("%d%d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    eval();

    while (q--) {
        scanf("%d%d", &x, &y);
        x--;
        y--;

        if (is_reachable(x, y)) {
            printf("Shi\n");
        } else {
            printf("Fou\n");
        }
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);

#pragma warning(disable : 6031)
#pragma warning(disable : 4101)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);

// Solution

const int MAXN = 300005;

int n, q, x, y, A[MAXN], Z[MAXN][20], DP[MAXN][20];

void eval() {
    for (int k = 0; k < 20; k++) {
        Z[n - 1][k] = n;
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            Z[i][k] = Z[i + 1][k];

            if ((A[i + 1] >> k) & 1) {
                Z[i][k] = i + 1;
            }
        }
    }

    for (int k = 0; k < 20; k++) {
        DP[n - 1][k] = n;

        if ((A[n - 1] >> k) & 1) {
            DP[n - 1][k] = n - 1;
        }
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            DP[i][k] = n;

            for (int s = 0; s < 20; s++) {
                if (((A[i] >> s) & 1) && Z[i][s] < n) {
                    DP[i][k] = min(DP[i][k], DP[Z[i][s]][k]);
                }
            }
        }
    }
}

bool is_reachable(int x, int y) {
    for (int k = 0; k < 20; k++) {
        if (((A[y] >> k) & 1) && DP[x][k] <= y) {
            return true;
        }
    }

    return false;
}

int main() {
    scanf("%d%d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    eval();

    while (q--) {
        scanf("%d%d", &x, &y);
        x--;
        y--;

        if (is_reachable(x, y)) {
            printf("Shi\n");
        } else {
            printf("Fou\n");
        }
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);

#pragma warning(disable : 6031)
#pragma warning(disable : 4101)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);

// Solution

const int MAXN = 300005;

int n, q, x, y, A[MAXN], Z[MAXN][20], DP[MAXN][20];

void eval() {
    for (int k = 0; k < 20; k++) {
        DP[n - 1][k] = n;
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            Z[i][k] = Z[i + 1][k];

            if ((A[i + 1] >> k) & 1) {
                Z[i][k] = i + 1;
            }
        }
    }

    for (int k = 0; k < 20; k++) {
        DP[n - 1][k] = n;

        if ((A[n - 1] >> k) & 1) {
            DP[n - 1][k] = n - 1;
        }
    }

    for (int i = n - 2; i >= 0; i--) {
        for (int k = 0; k < 20; k++) {
            DP[i][k] = n;

            for (int s = 0; s < 20; s++) {
                if (((A[i] >> s) & 1) && Z[i][s] < n) {
                    DP[i][k] = min(DP[i][k], DP[Z[i][s]][k]);
                }
            }
        }
    }
}

bool is_reachable(int x, int y) {
    for (int k = 0; k < 20; k++) {
        if (((A[y] >> k) & 1) && DP[x][k] <= y) {
            return true;
        }
    }

    return false;
}

int main() {
    scanf("%d%d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    eval();

    while (q--) {
        scanf("%d%d", &x, &y);
        x--;
        y--;

        if (is_reachable(x, y)) {
            printf("Shi\n");
        } else {
            printf("Fou\n");
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : (rch[i][k] <= j));
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20;k++)
			if(v[j] && (1 << k))
				ans = (ans == 1 ? 1 : rch[i][k]);
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	memset(rch, 0x3f3f3f3f, sizeof rch);
	scanf("%d %d", &n, &q);
	for(int i = 1;i <= n;i++)
		scanf("%d", &v[i]);
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		scanf("%d %d", &i, &j);
		for(int k = 0;k < 20 && !ans;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : (rch[i][k] <= j));
		printf(ans ? "Shi\n" : "Fou\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20 && !ans;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : (rch[i][k] <= j));
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : rch[i][k]);
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : (rch[i][k] <= j));
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	memset(rch, 0x3f3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20 && !ans;k++)
			if(v[j] & (1 << k))
				ans = (ans == 1 ? 1 : (rch[i][k] <= j));
		cout << (ans ? "Shi\n" : "Fou\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

int n, q, nxt[20], rch[300100][20], v[300100];

int main(){
	memset(rch, 0x3f3f3f, sizeof rch);
	cin >> n >> q;
	for(int i = 1;i <= n;i++)
		cin >> v[i];
	for(int i = n;i >= 1;i--){
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j))
				rch[i][j] = i;
		for(int j = 0;j < 20;j++)
			if(v[i] & (1 << j)){
				if(nxt[j]){
					for(int k = 0;k < 20;k++)
						rch[i][k] = min(rch[i][k], rch[nxt[j]][k]);
				}
				nxt[j] = i;
			}
	}
	while(q--){
		int i, j;
		bool ans = 0;
		cin >> i >> j;
		for(int k = 0;k < 20;k++)
			if(v[j] && (1 << k))
				ans = (ans == 1 ? 1 : rch[i][k]);
		cout << (ans ? "Shi" : "Fou") << endl;
	}
}


#include<bits/stdc++.h>
#define MAXN 300005
#define INF 16843009
using namespace std;

int N,Q;

int a[MAXN];
int go[MAXN][35], last[MAXN][35];

/*
go[i][j] = i, if a[i] has bit j
         = min{go[last[i][k]][j]}, if a[i] has bit k, but no bit j

*/

void init(){
	memset(last,1,sizeof(last));
	memset(go,1,sizeof(go));

	for(int i=N;i>=1;i--){
		for(int j=0;j<20;j++){
			last[i][j] = last[i+1][j];
		}

		for(int j=0;j<20;j++){
			for(int k=0;k<20;k++){
				if((a[i]>>k)&1){
					if(last[i][k] <= N) go[i][j] = min(go[i][j], go[last[i][k]][j]);
				}
			}
		}

		for(int j=0;j<20;j++){
			if((a[i]>>j)&1) last[i][j] = go[i][j] = i;
		}
	}
}

int main(){
	ios::sync_with_stdio(0);

	cin>>N>>Q;

	for(int i=1;i<=N;i++){
		cin>>a[i];
	}

	init();

	int x,y;
	int ok;
	while(Q--){
		ok = 0;
		cin>>x>>y;

		for(int j=0;j<20;j++){
			if((a[y]>>j)&1){
				if(go[x][j] <= y){
					ok = 1;
					break;
				}
			}
		}

		if(ok) cout<<"Shi"<<endl;
		else cout<<"Fou"<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define MAXN 300005
#define INF (1<<25)
#define P int(1e9+7)
using namespace std;

int N;
string s;

bool chk(int l, int r){
	for(int len=1;2*len<=r-l+1;++len){
		for(int i=l;i+2*len<=r;i++){
			if(s[l]==s[l+len] && s[l+len]==s[l+2*len]) return 1;
		}
	}
	return 0;
}

int work(int l){
	for(int r=l+2;r<=N;r++){
		if(chk(l,r)) return r;
	}
	return N+1;
}

int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	N = s.length();
	s = "%" + s;

	LL ans = 0;
	int r;
	for(int i=1;i<=N;i++){
		r = work(i);
		if(r <= N) ans += N - r + 1;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 300005
#define INF 16843009
using namespace std;

int N,Q;

int a[MAXN];
int go[MAXN][35], last[MAXN][35];

/*
go[i][j] = i, if a[i] has bit j
         = min{go[last[i][k]][j]}, if a[i] has bit k, but no bit j

*/

void init(){
	memset(last,1,sizeof(last));
	memset(go,1,sizeof(go));

	for(int i=N;i>=1;i--){
		for(int j=0;j<30;j++){
			last[i][j] = last[i+1][j];
		}

		for(int j=0;j<30;j++){
			for(int k=0;k<30;k++){
				if((a[i]>>k)&1){
					if(last[i][k] <= N) go[i][j] = min(go[i][j], go[last[i][k]][j]);
				}
			}
		}

		for(int j=0;j<30;j++){
			if((a[i]>>j)&1) last[i][j] = go[i][j] = i;
		}
	}
}

int main(){
	ios::sync_with_stdio(0);

	cin>>N>>Q;

	for(int i=1;i<=N;i++){
		cin>>a[i];
	}

	init();

	int x,y;
	int ok;
	while(Q--){
		ok = 0;
		cin>>x>>y;

		for(int j=0;j<30;j++){
			if((a[y]>>j)&1){
				if(go[x][j] <= y){
					ok = 1;
					break;
				}
			}
		}

		if(ok) cout<<"Shi"<<endl;
		else cout<<"Fou"<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define fi first
#define se second
#define pll pair<ll, ll>
#define m_p make_pair
#define p_b push_back
#define all(v) v.begin(), v.end()
#define sqr(x)  (x) * (x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 3e5 + 5;
const ll M = 20;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}

ll dp[111][111], f[N][30];

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);

    ll n, q;
    cin >> n >> q;
    vector <ll> a(n);

    for(int i = 0; i < n; i++)cin >> a[i];

    for(int i = 0; i < M; i++)
        for(int j = 0; j < M; j++)dp[i][j] = 1e18;

    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < M; j++)f[i][j] = 1e18;

        for(int j = 0; j < M; j++)if((pw(j) & a[i])){
            f[i][j] = i;
            for(int k = 0; k < M; k++)f[i][k] = min(f[i][k], dp[j][k]);
        }

        for(int j = 0; j < M; j++)if((pw(j) & a[i])){
            for(int k = 0; k < M; k++)dp[j][k] = min(dp[j][k], f[i][k]);
        }

    }

    while(q--){
        ll x, y;
        cin >> x >> y;
        x--, y--;
        ll ans = 1e18;
        for(int i = 0; i < M; i++)if((a[y] & pw(i)))ans = min(ans, f[x][i]);
        if(ans <= y)cout << "Shi\n"; else cout << "Fou\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define fi first
#define se second
#define pll pair<ll, ll>
#define m_p make_pair
#define p_b push_back
#define all(v) v.begin(), v.end()
#define sqr(x)  (x) * (x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 3e5 + 5;
const ll M = 20;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}

ll dp[111][111], f[N][30];

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);

    ll n, q;
    cin >> n >> q;
    vector <ll> a(n);

    for(int i = 0; i < n; i++)cin >> a[i];

    for(int i = 0; i < M; i++)
        for(int j = 0; j < M; j++)dp[i][j] = 1e18;

    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < M; j++)f[i][j] = 1e18;

        for(int j = 0; j < M; j++)if(!(pw(j) & a[i])){
            f[i][j] = i;
            for(int k = 0; k < M; k++)f[i][k] = min(f[i][k], dp[j][k]);
        }

        for(int j = 0; j < M; j++)if(!(pw(j) & a[i])){
            for(int k = 0; k < M; k++)dp[j][k] = min(dp[j][k], f[i][k]);
        }

    }

    while(q--){
        ll x, y;
        cin >> x >> y;
        x--, y--;
        ll ans = 1e18;
        for(int i = 0; i < M; i++)if((a[y] & pw(i)))ans = min(ans, f[x][i]);
        if(ans != 1e18)cout << "Shi\n"; else cout << "Fou\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define fi first
#define se second
#define pll pair<ll, ll>
#define m_p make_pair
#define p_b push_back
#define all(v) v.begin(), v.end()
#define sqr(x)  (x) * (x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 3e5 + 5;
const ll M = 20;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl; exit(0);}

ll dp[111][111], f[N][30];

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);

    ll n, q;
    cin >> n >> q;
    vector <ll> a(n);

    for(int i = 0; i < n; i++)cin >> a[i];

    for(int i = 0; i < M; i++)
        for(int j = 0; j < M; j++)dp[i][j] = 1e18;

    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j < M; j++)f[i][j] = 1e18;

        for(int j = 0; j < M; j++)if(!(pw(j) & a[i])){
            f[i][j] = i;
            for(int k = 0; k < M; k++)f[i][k] = min(f[i][k], dp[j][k]);
        }

        for(int j = 0; j < M; j++)if(!(pw(j) & a[i])){
            for(int k = 0; k < M; k++)dp[j][k] = min(dp[j][k], f[i][k]);
        }

    }

    while(q--){
        ll x, y;
        cin >> x >> y;
        x--, y--;
        ll ans = 1e18;
        for(int i = 0; i < M; i++)if((a[y] & pw(i)))ans = min(ans, f[x][i]);
        if(ans < y)cout << "Shi\n"; else cout << "Fou\n";
    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=300010;
int a[maxn],dp[maxn][20],pre[20];
int main()
{
    int N,Q,L,R;
    scanf("%d%d",&N,&Q);
    rep(i,1,N) scanf("%d",&a[i]);
    for(int i=N;i>=1;i--){
        rep(j,0,19) if(pre[j]){
            int P=pre[j];
            if((a[i]&a[P])!=0&&((a[P]>>j)&1)&&(!dp[i][j]||dp[i][j]>P)) dp[i][j]=P;
            rep(k,0,19) {
                if(!dp[P][k]||(a[i]&a[P])==0) continue;
                if(!dp[i][k]||dp[i][k]>dp[P][k])
                  dp[i][k]=dp[P][k];
            }
        }
        rep(j,0,19) if(a[i]&(1<<j)) pre[j]=i;
    }
    rep(i,1,Q){
        scanf("%d%d",&L,&R);
        int F=0;
        rep(j,0,19) if(dp[L][j]&&dp[L][j]<=R&&(a[R]>>j)&1) F=1;
        if(F) puts("Shi");
        else puts("Fou");
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=300010;
int a[maxn],dp[maxn][20],pre[20];
int main()
{
    int N,Q,L,R;
    scanf("%d%d",&N,&Q);
    rep(i,1,N) scanf("%d",&a[i]);
    for(int i=N;i>=1;i--){
        rep(j,0,19) if(pre[j]){
            int P=pre[j];
            if((a[i]&a[P])!=0&&(!dp[i][j]||dp[i][j]>P)) dp[i][j]=P;
            rep(k,0,19) {
                if(!dp[P][k]||(a[i]&a[P])!=0) continue;
                if(!dp[i][k]||dp[i][k]>dp[P][k])
                  dp[i][k]=dp[P][k];
            }
        }
        rep(j,0,19) if(a[i]&(1<<j)) pre[j]=i;
    }
    rep(i,1,Q){
        scanf("%d%d",&L,&R);
        int F=0;
        rep(j,0,19) if(dp[L][j]<=R&&(a[R]>>j)&1) F=1;
        if(F) puts("Shi");
        else puts("Fou");
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=300010;
int a[maxn],dp[maxn][20],pre[20];
int main()
{
    int N,Q,L,R;
    scanf("%d%d",&N,&Q);
    rep(i,1,N) scanf("%d",&a[i]);
    for(int i=N;i>=1;i--){
        rep(j,0,19) if(pre[j]){
            int P=pre[j];
            if((a[i]&a[P])!=0&&((a[P]>>j)&1)&&(!dp[i][j]||dp[i][j]>P)) dp[i][j]=P;
            rep(k,0,19) {
                if(!dp[P][k]||(a[i]&a[P])!=0) continue;
                if(!dp[i][k]||dp[i][k]>dp[P][k])
                  dp[i][k]=dp[P][k];
            }
        }
        rep(j,0,19) if(a[i]&(1<<j)) pre[j]=i;
    }
    rep(i,1,Q){
        scanf("%d%d",&L,&R);
        int F=0;
        rep(j,0,19) if(dp[L][j]<=R&&(a[R]>>j)&1) F=1;
        if(F) puts("Shi");
        else puts("Fou");
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=300010;
int a[maxn],dp[maxn][20],pre[20];
int main()
{
    int N,Q,L,R;
    scanf("%d%d",&N,&Q);
    rep(i,1,N) scanf("%d",&a[i]);
    for(int i=N;i>=1;i--){
        rep(j,0,19) if(pre[j]){
            int P=pre[j];
            if((a[i]&a[P])!=0&&(!dp[i][j]||dp[i][j]>P)) dp[i][j]=P;
            rep(k,0,19) {
                if(!dp[P][k]||(a[i]&a[P])!=0) continue;
                if(!dp[i][k]||dp[i][k]>dp[P][k])
                  dp[i][k]=dp[P][k];
            }
        }
        rep(j,0,19) if(a[i]&(1<<j)) pre[j]=i;
    }
    rep(i,1,Q){
        scanf("%d%d",&L,&R);
        int F=0;
        rep(j,0,19) if(dp[L][j]<=R&&(a[R]>>j)&1) F=1;
        if(F) puts("SHI");
        else puts("FOU");
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=300010;
int a[maxn],dp[maxn][20],pre[20];
int main()
{
    int N,Q,L,R;
    scanf("%d%d",&N,&Q);
    rep(i,1,N) scanf("%d",&a[i]);
    for(int i=N;i>=1;i--){
        rep(j,0,19) if(pre[j]){
            int P=pre[j];
            if((a[i]&a[P])!=0&&((a[P]>>j)&1)&&(!dp[i][j]||dp[i][j]>P)) dp[i][j]=P;
            rep(k,0,19) {
                if(!dp[P][k]||(a[i]&a[P])==0) continue;
                if(!dp[i][k]||dp[i][k]>dp[P][k])
                  dp[i][k]=dp[P][k];
            }
        }
        rep(j,0,19) if(a[i]&(1<<j)) pre[j]=i;
    }
    rep(i,1,Q){
        scanf("%d%d",&L,&R);
        int F=0;
        rep(j,0,19) if(dp[L][j]<=R&&(a[R]>>j)&1) F=1;
        if(F) puts("Shi");
        else puts("Fou");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 300005;
int a[maxn],dp[maxn][30],c[30];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,q;
    cin>>n>>q;
    for(int i = 1;i<=n;i++) cin>>a[i];
    memset(c,-1,sizeof(c));
    memset(dp,0x3f,sizeof(dp));
    for(int i = n;i>=1;i--){
        for(int j = 0;j<=20;j++){
            if((a[i]>>j)&1){
                dp[i][j] = i;
                c[j] = i;
                if(c[j]!=-1){
                    for(int k = 0;k<=20;k++){
                        dp[i][k] = min(dp[i][k],dp[c[j]][k]);
                    }
                }
            }
        }
    }
    while(q--){
        int x,y,flag = 0;
        cin>>x>>y;
        for(int i = 0;i<=20;i++){
            if((a[y]>>1)&1){
                if(dp[x][i]<=y) flag = 1;
            }
        }
        if(flag) cout<<"Shi"<<endl;
        else cout<<"Fou"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3000005;
int a[maxn],dp[maxn][30],c[30];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,q;
    cin>>n>>q;
    for(int i = 1;i<=n;i++) cin>>a[i];
    memset(c,-1,sizeof(c));
    memset(dp,0x3f,sizeof(dp));
    for(int i = n;i>=1;i--){
        for(int j = 0;j<=20;j++){
            if((a[i]>>j)&1){
                dp[i][j] = i;
                c[j] = i;
                if(c[j]!=-1){
                    for(int k = 0;k<=20;k++){
                        dp[i][k] = min(dp[i][k],dp[c[j]][k]);
                    }
                }
            }
        }
    }
    while(q--){
        int x,y,flag = 0;
        cin>>x>>y;
        for(int i = 0;i<=20;i++){
            if((a[y]>>1)&1){
                if(dp[x][i]<=y) flag = 1;
            }
        }
        if(flag) cout<<"Shi"<<endl;
        else cout<<"Fou"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 300005;
int a[maxn],dp[maxn][30],c[30];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,q;
    cin>>n>>q;
    for(int i = 1;i<=n;i++) cin>>a[i];
    memset(c,-1,sizeof(c));
    memset(dp,0x3f,sizeof(dp));
    for(int i = n;i>=1;i--){
        for(int j = 0;j<=20;j++){
            if((a[i]>>j)&1){
                dp[i][j] = i;
                //c[j] = i;
                if(c[j]!=-1){
                    for(int k = 0;k<=20;k++){
                        dp[i][k] = min(dp[i][k],dp[c[j]][k]);
                    }
                }
                c[j] = i;
            }
        }
    }
    while(q--){
        int x,y,flag = 0;
        cin>>x>>y;
        for(int i = 0;i<=20;i++){
            if((a[y]>>i)&1){
                if(dp[x][i]<=y) flag = 1;
            }
        }
        if(flag) cout<<"Shi"<<endl;
        else cout<<"Fou"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS(); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    IOS();

}


#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <limits.h>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j123 = n; (i) < j123; (i) ++)
#define rep1(i, n) for (int (i) = 1, j123 = n; (i) <= j123; (i) ++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout << #a << " :";for(int i123=(x);i123<=(y);i123++) cout<<setw(4)<<(a)[i123];cout<<endl;}
#define clr(x) memset(x,0,sizeof(x));
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define endl '\n'
typedef long long ll;
typedef long double ld;
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
// const int MOD = ;

ll n, d, x;
ll a[100100];
ll b[100100];
ll sumb[100100];
//x is 64-bit variable;
int getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
int initAB() {
  int i;
  for(i = 0; i < n; i = i + 1){
    a[i] = i + 1;
  }
  for(i = 0; i < n; i = i + 1){
    swap(a[i], a[getNextX() % (i + 1)]);
  }
  for(i = 0; i < n; i = i + 1){
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  }
  for(i = 0; i < n; i = i + 1){
    swap(b[i], b[getNextX() % (i + 1)]);
  }
}
int loc[100100];
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0);
  cin >> n >> d >> x;
  initAB();
  for (int i = 0; i < n; i++)
    loc[a[i]] = i;
  for (int i = 0; i < n; i++)
    if (i > 0)
      sumb[i] = b[i] + sumb[i-1];
  vector<int> indexForB;
  for (int i = 0; i < n; i++)
    if (b[i] > 0)
      indexForB.pb(i);

  priority_queue< pair<int,int> > pq;
  for (int i = 0; i < n; i++)
  {
    // calculate c[i]
    ll ans = 0;
    pq.push(mp(a[i],i));
    if (sumb[i] < 3e3)
    {
      // bruteforce
      for (int ii = 0; ii < sz(indexForB); ii++)
      {
        int ind = indexForB[ii];
        if (ind <= i)
        {
          ans = max(ans, a[i-ind]);
        }
        else
        {
          break;
        }
      }
    }
    else
    {
      stack< pair<int,int> > stk;
      while (!pq.empty())
      {
        int Aj = pq.top().first;
        int j = pq.top().second;
        pq.pop();
        stk.push(mp(Aj,j));
        if (b[i-j] == 1)
        {
          ans = Aj;
          while (!stk.empty())
          {
            pq.push(stk.top());
            stk.pop();
          }
          break;
        }
      }
    }
    cout << ans << endl;
  }
}