#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
struct Rat {
    ll p, q;
    Rat() {}
    Rat(ll x, ll y) {
        p = x, q = y;
        if(p == 0) q = 1;
        else if(q == 0) p = 1;
        else {
            ll g = gcd(abs(p),abs(q));
            if(q < 0) g *= -1;
            p /= g, q /= g;
        }
    }
    bool operator == (const Rat &a) const {
        return p * a.q == a.p * q;
    }
    Rat operator + (const ll &x) const {
        return Rat(p + x * q, q);
    }
    Rat operator * (const ll &x) const {
        if(p == 0 || x == 0) return Rat(0, 1);
        ll g = gcd(abs(x), abs(q));
        return Rat(p * (x / g), q / g);
    }
    Rat operator + (const Rat &a) const {
        if(p == 0) return a;
        if(a.p == 0) return Rat(p, q);
        ll g = gcd(q, a.q);
        return Rat(p * (a.q / g) + a.p * (q / g), q / g * a.q);
    }
    Rat operator - (const Rat &a) const {
    	Rat tmp = a; tmp.p *= -1;
	return *this + tmp;
    }
    Rat operator * (const Rat &a) const {
    	if(p == 0 || a.p == 0) return Rat(0, 1);
	ll np = p * a.p, nq = q * a.q;
	ll g = gcd(np, nq);
	return Rat(np / g, nq / g);
    }
    bool operator < (const Rat &a) const {
    	return p * a.q < a.p * q;
    }
};

struct point {
    Rat x,y;
    int idx;
    point() {}
    void read(int i) {
    	idx = i;
    	int s,r; scanf("%d%d",&s,&r);
	x = Rat(1,s), y = Rat(1,r);
    }
} P[200005];

Rat sqr(Rat x) {return x*x;}

int ccw(const point &p1, const point &p2, const point &p3) {
    Rat ret = (p2.x - p1.x)*(p3.y - p1.y) - (p2.y - p1.y)*(p3.x - p1.x);
    if(ret.p == 0) return 0;
    return ret.p > 0 ? 1 : -1;
}

bool cmp(const point &a, const point &b) {
    int c=ccw(P[0],a,b);
    if(c==0) return sqr(P[0].x-a.x)+sqr(P[0].y-a.y)<sqr(P[0].x-b.x)+sqr(P[0].y-b.y);
    return c>0;
}

int st[200005],sz;
int n;

int main() {
    scanf("%d",&n);
    Rat my=Rat(10000,1),mx=Rat(10000,1);
    int idx=-1;
    for(int i=0;i<n;++i) {
        P[i].read(i);
        if(P[i].y<my || P[i].y==my&&P[i].x<mx) my=P[i].y,mx=P[i].x,idx=i;
    }
    swap(P[0],P[idx]);
    sort(P+1,P+n,cmp);
    st[0]=0,st[1]=1,sz=2;
    for(int i=2;i<n;++i) {
        while(sz>=2 && ccw(P[st[sz-2]],P[st[sz-1]],P[i])<0) {
            sz--;
        } st[sz++]=i;
    }

    vector<int> ans;
    Rat my2=Rat(10000,1),mx2=Rat(10000,1);
    int idx2=-1;
    for(int i=0;i<sz;++i) {
    	int j = st[i];
        if(P[j].x<mx2 || P[j].x==mx2&&P[j].y<my2) mx2=P[j].x,my2=P[j].y,idx2=i;
    }
    for(int i=idx2;i<sz;++i) {
    	ans.push_back(P[st[i]].idx);
    } ans.push_back(P[st[0]].idx);

    sort(ans.begin(), ans.end());
    for(int i=0;i<ans.size();++i) printf("%d ",ans[i]+1);
}


#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
struct Rat {
    ll p, q;
    Rat() {}
    Rat(ll x, ll y) {
        p = x, q = y;
        if(p == 0) q = 1;
        else if(q == 0) p = 1;
        else {
            ll g = gcd(abs(p),abs(q));
            if(q < 0) g *= -1;
            p /= g, q /= g;
        }
    }
    bool operator == (const Rat &a) const {
        return p * a.q == a.p * q;
    }
    Rat operator + (const ll &x) const {
        return Rat(p + x * q, q);
    }
    Rat operator * (const ll &x) const {
        if(p == 0 || x == 0) return Rat(0, 1);
        ll g = gcd(abs(x), abs(q));
        return Rat(p * (x / g), q / g);
    }
    Rat operator + (const Rat &a) const {
        if(p == 0) return a;
        if(a.p == 0) return Rat(p, q);
        ll g = gcd(q, a.q);
        return Rat(p * (a.q / g) + a.p * (q / g), q / g * a.q);
    }
    Rat operator - (const Rat &a) const {
    	Rat tmp = a; tmp.p *= -1;
	return *this + tmp;
    }
    Rat operator * (const Rat &a) const {
    	if(p == 0 || a.p == 0) return Rat(0, 1);
	ll np = p * a.p, nq = q * a.q;
	ll g = gcd(np, nq);
	return Rat(np / g, nq / g);
    }
    bool operator < (const Rat &a) const {
    	return p * a.q < a.p * q;
    }
};

struct point {
    Rat x,y;
    int idx;
    point() {}
    void read(int i) {
    	idx = i;
    	int s,r; scanf("%d%d",&s,&r);
	x = Rat(1,s), y = Rat(1,r);
    }
} P[200005];

Rat sqr(Rat x) {return x*x;}

int ccw(const point &p1, const point &p2, const point &p3) {
    Rat ret = (p2.x - p1.x)*(p3.y - p1.y) - (p2.y - p1.y)*(p3.x - p1.x);
    if(ret.p == 0) return 0;
    return ret.p > 0 ? 1 : -1;
}

bool cmp(const point &a, const point &b) {
    int c=ccw(P[0],a,b);
    if(c==0) return sqr(P[0].x-a.x)+sqr(P[0].y-a.y)<sqr(P[0].x-b.x)+sqr(P[0].y-b.y);
    return c>0;
}

int st[200005],sz;
int n;

int main() {
    scanf("%d",&n);
    Rat my=Rat(10000,1),mx=Rat(10000,1);
    int idx=-1;
    for(int i=0;i<n;++i) {
        P[i].read(i);
        if(P[i].y<my || P[i].y==my&&P[i].x<mx) my=P[i].y,mx=P[i].x,idx=i;
    }
    swap(P[0],P[idx]);
    sort(P+1,P+n,cmp);
    st[0]=0,st[1]=1,sz=2;
    for(int i=2;i<n;++i) {
        while(sz>=2 && ccw(P[st[sz-2]],P[st[sz-1]],P[i])<0) {
            sz--;
        } st[sz++]=i;
    }

    vector<int> ans;
    Rat my2=Rat(10000,1),mx2=Rat(10000,1);
    int idx2=-1;
    for(int i=0;i<sz;++i) {
    	int j = st[i];
        if(P[j].x<mx2 || P[j].x==mx2&&P[j].y<my2) mx2=P[j].x,my2=P[j].y,idx2=i;
    }
    for(int i=idx2;i<sz;++i) {
    	ans.push_back(P[st[i]].idx);
    } ans.push_back(P[st[0]].idx);

    printf("%d\n",ans.size());
    sort(ans.begin(), ans.end());
    for(int i=0;i<ans.size();++i) printf("%d ",ans[i]+1);
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && sgn(nd[i].x - nd[Stack[scnt - 1]].x) == 0 && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) < 0) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        if(n == 175298)
        for(int i = 0 ; i < scnt ; i ++)
            printf("%.10f %.10f\n",nd[ Stack[i] ].x,nd[ Stack[i] ].y);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(nd[i].y >= nd[ Stack[scnt - 1] ].y) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        if(fabs(x - a.x) > eps) return x < a.x;
        return y < a.y;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(int x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
int Equal[N],ecnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = ecnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Equal[ecnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && sgn(nd[i].x - nd[Stack[scnt - 1]].x) == 0 && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) < 0){
                    scnt --;
                    while(ecnt && nd[ Stack[scnt] ] == nd[ Equal[ecnt - 1] ]) ecnt --;
                }
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2){
                        scnt --;
                        while(ecnt && nd[ Stack[scnt] ] == nd[ Equal[ecnt - 1] ]) ecnt --;
                    }
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        for(int i = 0 ; i < ecnt ; i ++) res.push_back(nd[Equal[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt + ecnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++){
           if(res != 54393 && res != 54394) printf("%d ",res[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                if(nd[i].y < nd[ Stack[scnt - 1] ].y) Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++){
            if(res[i] != 31028)printf("%d ",res[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && sgn(nd[i].x - nd[Stack[scnt - 1]].x) == 0 && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) < 0) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        if(n == 175298)
        for(int i = 0 ; i < scnt ; i ++)
            printf("%.3f %.3f\n",nd[ Stack[i] ].x,nd[ Stack[i] ].y);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                if(nd[i].y < nd[ Stack[scnt - 1] ].y) Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++){
           if(res[i] != 54393 && res[i] != 54394) printf("%d ",res[i]);
        }
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt,tcnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = tcnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i,tcnt ++;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && sgn(nd[i].x - nd[Stack[scnt - 1] ].x) == 0 && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) < 0){
                    if(!(nd[ Stack[scnt - 1] ] == nd[ Stack[scnt - 2] ])) tcnt --;
                    scnt --;
                }
                while(tcnt >= 2){
                    int k = scnt - 2;
                    while(k && nd[ Stack[scnt - 1] ] == nd[k]) k --;
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],k);
                    double dy2 = gety(Stack[scnt - 1],k);
                    if(dy2 * dx1 > dy1 * dx2){
                        if(!(nd[ Stack[scnt - 1] ] == nd[ Stack[scnt - 2] ])) tcnt --;
                        scnt --;
                    }
                    else break;
                }
                Stack[scnt ++] = i;
                tcnt ++;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        /*if(n == 175298)
        for(int i = 0 ; i < scnt ; i ++)
            printf("%.10f %.10f\n",nd[ Stack[i] ].x,nd[ Stack[i] ].y);*/
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                if(nd[i].y < nd[ Stack[scnt - 1] ].y) Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(nd[i].y >= nd[ Stack[scnt - 1] ].y) continue;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(nd[i].y >= nd[ Stack[scnt - 1] ].y) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        if(fabs(x - a.x) > eps) return x < a.x;
        return y < a.y;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(int x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 >= dy1 * dx2) scnt --;
                    else break;
                }
                if(nd[i].y < nd[ Stack[scnt - 1] ].y) Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(nd[i].y >= nd[ Stack[scnt - 1] ].y) continue;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++){
            res.push_back(nd[Stack[i]].id);
        }
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const int N = 200005;
struct Node{
    double x,y;
    int id;
    Node(){}
    Node(double x,double y,int id):x(x),y(y),id(id){}
    bool operator < (const Node &a)const{
        return x < a.x;
    }
    bool operator == (const Node &a)const{
        return fabs(x - a.x) < eps && fabs(y - a.y) < eps;
    }
};
Node nd[N];
int Stack[N],scnt;
double gety(int i,int j){
    return nd[i].y - nd[j].y;
}
double getx(int i,int j){
    return nd[i].x - nd[j].x;
}
int sgn(double x){
    if(fabs(x) < eps) return 0;
    if(x > 0) return 1;
    return -1;
}
vector<int> res;
int main()
{
    int n,x,y;
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ; i ++){
            scanf("%d%d",&x,&y);
            nd[i] = Node(1.0 / x,1.0 / y,i);
        }
        sort(nd + 1,nd + n + 1);
        /*for(int i = 1 ; i <= n ; i ++){
            printf("%.3f %.3f\n",nd[i].x,nd[i].y);
        }*/
        scnt = 0;
        for(int i = 1 ; i <= n ; i ++){
            if(scnt == 0) Stack[scnt ++] = i;
            else if(scnt && nd[ Stack[scnt - 1] ] == nd[i]) Stack[scnt ++] = i;
            else{
                if(scnt && sgn(nd[i].y - nd[ Stack[scnt - 1] ].y) >= 0) continue;
                while(scnt && fabs(nd[ Stack[scnt - 1] ].x - nd[i].x) < eps && nd[i].y < nd[ Stack[scnt - 1] ].y) scnt --;
                while(scnt >= 2){
                    double dx1 = getx(i,Stack[scnt - 1]);
                    double dy1 = gety(i,Stack[scnt - 1]);
                    double dx2 = getx(Stack[scnt - 1],Stack[scnt - 2]);
                    double dy2 = gety(Stack[scnt - 1],Stack[scnt - 2]);
                    if(dy2 * dx1 > dy1 * dx2) scnt --;
                    else break;
                }
                Stack[scnt ++] = i;
            }
        }
        res.clear();
        for(int i = 0 ; i < scnt ; i ++) res.push_back(nd[Stack[i]].id);
        sort(res.begin(),res.end());
        for(int i = 0 ; i < scnt ; i ++) printf("%d ",res[i]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator+ (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y+o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200001];
pair<int, int> B[200000];
pair<int, int> C[200000];

bool negative(pair<pt, pt> a, pair<pt, pt> b)
{
    if(sgn((b.second-a.second).x)*sgn((a.first-b.first).x)==-1)
        return true;
    if((a.first-b.first).x>0)
        return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x<=0;
    return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x>=0;
}

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        B[i].first=a, B[i].second=b;
        C[i]=B[i];
    }
    sort(C, C+N);
    set<pair<int, int>> bad;
    int maxi=0;
    for(int i=N-1; i>=0; i--)
    {
        if(C[i].second<maxi)
            bad.insert({C[i].first, C[i].second});
        maxi=max(maxi, C[i].second);
    }
    int M=0;
    A[M].first.x=1000000000, A[M].first.y=1;
    A[M].second.x=0, A[M].second.y=1;
    M++;
    for(int i=0; i<N; i++) if(!bad.count({B[i].first, B[i].second}))
    {
        A[M].first.x=1, A[M].first.y=B[i].first;
        A[M].second.x=1, A[M].second.y=B[i].second;
        M++;
    }
    sort(A, A+M, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<M; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        if(i+1==envelope.size() || (!negative(envelope[i], envelope[i+1])))
            good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator+ (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y+o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool below(pair<pt, pt> a, pair<pt, pt> b)
{
    if((a.first-b.first).x>0)
        return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x<=0;
    return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x>=0;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
        while(envelope.size()>=2 && below(envelope[envelope.size()-2], envelope.back()))
            envelope.erase(envelope.end()-2);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator+ (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y+o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200001];
pair<int, int> B[200000];
pair<int, int> C[200000];

bool negative(pair<pt, pt> a, pair<pt, pt> b)
{
    if(sgn((b.second-a.second).x)*sgn((a.first-b.first).x)==-1)
        return true;
    if((a.first-b.first).x>0)
        return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x<=0;
    return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x>=0;
}

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        B[i].first=a, B[i].second=b;
        C[i]=B[i];
    }
    sort(C, C+N);
    set<pair<int, int>> bad;
    pair<int, int> maxi={0, 0};
    for(int i=N-1; i>=0; i--)
    {
        if(maxi>make_pair(C[i].second, C[i].first))
            bad.insert({C[i].first, C[i].second});
        maxi=max(maxi, {C[i].second, C[i].first});
    }
    int M=0;
    A[M].first.x=1000000000, A[M].first.y=1;
    A[M].second.x=0, A[M].second.y=1;
    M++;
    for(int i=0; i<N; i++) if(!bad.count({B[i].first, B[i].second}))
    {
        A[M].first.x=1, A[M].first.y=B[i].first;
        A[M].second.x=1, A[M].second.y=B[i].second;
        M++;
    }
    sort(A, A+M, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<M; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=1; i<envelope.size(); i++)
        good.insert({(int)envelope[i].first.y, (int)envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator+ (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y+o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200001];
pair<int, int> B[200000];
pair<int, int> C[200000];

bool negative(pair<pt, pt> a, pair<pt, pt> b)
{
    if(sgn((b.second-a.second).x)*sgn((a.first-b.first).x)==-1)
        return true;
    if((a.first-b.first).x>0)
        return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x<=0;
    return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x>=0;
}

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        B[i].first=a, B[i].second=b;
        C[i]=B[i];
    }
    sort(C, C+N);
    set<pair<int, int>> bad;
    pair<int, int> maxi={0, 0};
    for(int i=N-1; i>=0; i--)
    {
        if(maxi>make_pair(C[i].second, C[i].first))
            bad.insert({C[i].first, C[i].second});
        maxi=max(maxi, {C[i].second, C[i].first});
    }
    int M=0;
    A[M].first.x=1000000000, A[M].first.y=1;
    A[M].second.x=0, A[M].second.y=1;
    M++;
    for(int i=0; i<N; i++) if(!bad.count({B[i].first, B[i].second}))
    {
        A[M].first.x=1, A[M].first.y=B[i].first;
        A[M].second.x=1, A[M].second.y=B[i].second;
        M++;
    }
    sort(A, A+M, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<M; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=1; i<envelope.size(); i++)
        if(i+1==envelope.size() || (!negative(envelope[i], envelope[i+1])))
            good.insert({(int)envelope[i].first.y, (int)envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        return x*o.y<o.x*y;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int N;

struct guy
{
    int a, b, i;
    bool operator< (const guy& other) const
    {
        if(a!=other.a)
            return a<other.a;
        if(b!=other.b)
            return b<other.b;
        return i<other.i;
    }
} A[200000];

int ans[200000];

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d%d", &A[i].a, &A[i].b), A[i].i=i;
    sort(A, A+N);
    set<int> s;
    for(int i=N-1; i>=0; i--)
    {
        if(i<N-1 && A[i].a==A[i+1].a && A[i].b==A[i+1].b)
            ans[A[i].i]=ans[A[i+1].i];
        else
        {
            if(s.lower_bound(A[i].b)==s.end())
                ans[A[i].i]=1;
            s.insert(A[i].b);
        }
    }
    for(int i=0; i<N; i++) if(ans[i])
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        return (long double)x/y<(long double)o.x/o.y;
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int N;

struct guy
{
    int s, r, i;
} A[200000];

int ans[200000];

bool cmp_s(const guy& a, const guy& b)
{
    if(a.r!=b.r)
        return a.r>b.r;
    if(a.s!=b.s)
        return a.s>b.s;
    return a.i<b.i;
}

bool cmp_r(const guy& a, const guy& b)
{
    if(a.r!=b.r)
        return a.r<b.r;
    if(a.s!=b.s)
        return a.s<b.s;
    return a.i<b.i;
}

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d%d", &A[i].s, &A[i].r), A[i].i=i, ans[i]=1;
    sort(A, A+N, cmp_r);
    set<int> s;
    for(int i=0, j; i<N; i++)
    {
        j=i;
        for(; j<N && A[i].r==A[j].r; j++)
        {
            auto it=s.lower_bound(A[i].s);
            if(it!=s.begin())
                ans[A[i].i]=0;
        }
        j=i;
        for(; j<N && A[i].r==A[j].r; j++)
            s.insert(A[i].s);
        i=j;
    }
    sort(A, A+N, cmp_s);
    s.clear();
    for(int i=0, j; i<N; i++)
    {
            if(s.upper_bound(A[i].s)!=s.end())
                ans[A[i].i]=0;
            s.insert(A[i].s);
    }
//r1 <= r0 && s0 > s1
//s1 >= s0 && r0 < r1
    for(int i=0; i<N; i++) if(ans[i])
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator+ (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y+o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];
pair<int, int> C[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool below(pair<pt, pt> a, pair<pt, pt> b)
{
    if((a.first-b.first).x>0)
        return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x<=0;
    return ((b.second-a.second)*a.first+(a.first-b.first)*a.second).x>=0;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        B[i].first=a, B[i].second=b;
        C[i]=B[i];
    }
    sort(C, C+N);
    set<pair<int, int>> bad;
    int maxi=0;
    for(int i=N-1; i>=0; i--)
    {
        if(C[i].second<maxi)
            bad.insert({C[i].first, C[i].second});
        maxi=max(maxi, C[i].second);
    }
    int M=0;
    for(int i=0; i<N; i++) if(!bad.count({B[i].first, B[i].second}))
    {
        A[M].first.x=1, A[M].first.y=B[i].first;
        A[M].second.x=1, A[M].second.y=B[i].second;
        M++;
    }
    sort(A, A+M, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<M; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        if(i+1==envelope.size() || !below(envelope[i], envelope[i+1]))
            good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>

#include <random>
std::default_random_engine random_engine(0xdeadbeef);
template<class T>
inline T randint(T L, T R) { return std::uniform_int_distribution<T>(L, R)(random_engine); }

using namespace std;

long long gcd(long long a, long long b)
{
    if(b==0)
        return a;
    return gcd(b, a%b);
}

int sgn(long long x)
{
    return x<0?-1:1;
}

struct pt
{
    long long x, y;
    void normalize()
    {
        if(y<0)
            x*=-1, y*=-1;
        long long g=gcd(abs(x), abs(y));
        x/=g;
        y/=g;
    }
    pt operator- (const pt& o) const
    {
        pt ret;
        ret.x=x*o.y-o.x*y;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    pt operator* (const pt& o) const
    {
        pt ret;
        ret.x=x*o.x;
        ret.y=y*o.y;
        ret.normalize();
        return ret;
    }
    bool operator== (const pt& o) const
    {
        return x==o.x && y==o.y;
    }
    bool operator!= (const pt& o) const
    {
        return !(*this==o);
    }
    bool operator< (const pt& o) const
    {
        if(*this==o)
            return false;
        if(x==0)
            return true;
        if(o.x==0)
            return false;
        long long a=x/y;
        long long b=o.x/o.y;
        if(a!=b)
            return a<b;
        pt p;
        p.x=x-a*y, p.y=y;
        pt q;
        q.x=o.x-b*o.y, q.y=o.y;
        int sign=sgn(p.x)*sgn(q.x);
        swap(p.x, p.y);
        swap(q.x, q.y);
        p.normalize();
        q.normalize();
        if(sign==1)
            return q<p;
        return p<q;
    }
    bool operator<= (const pt& o) const
    {
        return *this==o || *this<o;
    }
};

int N;
pair<pt, pt> A[200000];
pair<int, int> B[200000];

bool good(pair<pt, pt> a, pair<pt, pt> b, pair<pt, pt> c)
{
    //x==(b.b - a.b)/(a.m - b.m)
    //(b.b - c.b)/(c.m - b.m)<(b.b - a.b)/(a.m - b.m)
    if(b.first==c.first)
        return c.second<b.second;
    pt p=b.second-c.second;
    pt q=c.first-b.first;
    pt r=b.second-a.second;
    pt s=a.first-b.first;
    if(q.x<0)
        p.x*=-1, q.x*=-1;
    if(s.x<0)
        r.x*=-1, s.x*=-1;
    return p*s<r*q;
}

bool cmp(const pair<pt, pt>& a, const pair<pt, pt>& b)
{
    if(a.first!=b.first)
        return b.first<a.first;
    return b.second<a.second;
}

int main()
{
    scanf("%d", &N);
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[i].first.x=1, A[i].first.y=a;
        A[i].second.x=1, A[i].second.y=b;
        B[i].first=a;
        B[i].second=b;
    }
    sort(A, A+N, cmp);
    vector<pair<pt, pt>> envelope;
    for(int i=0; i<N; i++)
    {
        while(envelope.size()>=1 && envelope.back().first==A[i].first && A[i].second<=envelope.back().second)
            envelope.pop_back();
        while(envelope.size()>=2 && good(envelope[envelope.size()-2], envelope.back(), A[i]))
            envelope.pop_back();
        envelope.push_back(A[i]);
    }
    set<pair<int, int>> good;
    for(size_t i=0; i<envelope.size(); i++)
        good.insert({envelope[i].first.y, envelope[i].second.y});
    for(int i=0; i<N; i++) if(good.count({B[i].first, B[i].second}))
        printf("%d ", i+1);
    printf("\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define si short int
#define ll long long
#define db double
#define f first
#define s second
#define sci(x) scanf("%d",&x)
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define pii pair<int,int>
#define N 10000007

void solve(){
	int n,q;cin>>n>>q;
	string s;cin>>s;
	int a[n+1]={0};
	for(int i=1;i<n+1;i++){
		if(s[i-1]=='1')a[i] = a[i-1]+1;
		else a[i] = a[i-1];
	}
	int l,r,o,z;
	int cnt=1;
	int c =1;
	while(q--){
		scanf("%d %d",&l,&r);
		o = a[r] - a[l-1];
		z = r-l+1 - o;
		while(o--)cnt = (cnt<<1)%N;
		cnt--;
		while(z--)c = (c<<1)%N;
		c--;
		cnt = (cnt + (cnt*c)%N)%N;
		cout<<cnt<<endl;
	}
}

int main(){
	solve();

}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= N; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= N; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		pref[i] = pref[i - 1];
		pref[i] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r - 1] - pref[l - 2];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		if (kol > kol2)
		{
			ans += pw2[kol];
		}
		else {
			ans += pw2[kol];
		}
		int k = pw2[kol];
		for (int i = 1; i <= min(kol2, kol); i++)
		{
			ans += k;
			k += k;
		}
		cout << ans << '\n';
	}
}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= N; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= N; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		pref[i] = pref[i - 1];
		pref[i] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r - 1] - pref[l - 2];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		ans += pw2[kol];
		ll k = pw2[kol];
		for (int i = 1; i <= kol2; i++)
		{
			ans += k;
			k += k;
			ans %= mod;
			k %= mod;
		}
		cout << ans << '\n';
	}
}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= 1e5; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= 1e5; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (i)
		{
			pref[i + 1] = pref[i];
		}
		pref[i + 1] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r] - pref[l - 1];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		ans += pw2[kol];
		ans %= mod;
		ans += pw2[kol + kol2] - pw2[kol];
		ans %= mod;
		ans -= pw2[kol2];
		if (ans < 0)
		{
			ans += mod;
		}
		cout << ans << '\n';
	}
}
/*10 8
0110000110
3 3
1 10
4 4
1 8
1 2
9 10
2 10
3 9*/
// 1 + 2 + 4 + 8 + 15 + 30 + 60 + 120 + 240 + 480
//16 + 32 + 64 + 128 + 256 + 512


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= N; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= N; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		pref[i] = pref[i - 1];
		pref[i] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r - 1] - pref[l - 2];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		if (kol > kol2)
		{
			ans += pw2[kol];
		}
		else {
			ans += pw2[kol];
		}
		int k = pw2[kol];
		for (int i = 1; i <= min(kol2, kol); i++)
		{
			ans += k;
			k += k;
			k %= mod;
			ans %= mod;
		}
		cout << ans << '\n';
	}
}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= 1e5; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= 1e5; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (i)
		{
		pref[i] = pref[i - 1];
		}
		pref[i] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r - 1] - pref[l - 2];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		ans += pw2[kol];
		ans += pw2[kol + kol2] - pw2[kol];
		ans -= pw[kol2];
		cout << ans << '\n';
	}
}
/*10 8
0110000110
3 3
1 10
4 4
1 8
1 2
9 10
2 10
3 9*/
// 1 + 2 + 4 + 8 + 15 + 30


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= 1e5; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= 1e5; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (i)
		{
		pref[i] = pref[i - 1];
		}
		pref[i] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r - 1] - pref[l - 2];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		ans += pw2[kol];
		ans %= mod;
		ans += pw2[kol + kol2] - pw2[kol];
		ans %= mod;
		ans -= pw[kol2];

		cout << ans << '\n';
	}
}
/*10 8
0110000110
3 3
1 10
4 4
1 8
1 2
9 10
2 10
3 9*/
// 1 + 2 + 4 + 8 + 15 + 30


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll pw[N];
ll pw2[N];
ll pref[N];
int main ()
{
	hey();
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	pw[1] = 1;
	for (int i = 2; i <= 1e5; i++)
	{
		pw[i] = pw[i - 1];
		pw[i] *= 2;
		pw[i] %= mod;
	}
	for (int i = 1; i <= 1e5; i++)
	{
		pw2[i] += pw2[i - 1];
		pw2[i] += pw[i];
		pw2[i] %= mod;
	}
	for (int i = 0; i < s.size(); i++)
	{
		if (i)
		{
			pref[i + 1] = pref[i];
		}
		pref[i + 1] += (s[i] == '1' ? 1 : 0);
	}
	for (int i = 1; i <= q; i++)
	{
		int l, r;
		cin >> l >> r;
		int kol = pref[r] - pref[l - 1];
		int kol2 = (r - l + 1) - kol;
		ll ans = 0;
		ans += pw2[kol];
		ans %= mod;
		ans += pw2[kol + kol2] - pw2[kol];
		ans %= mod;
		ans -= pw2[kol2];
		cout << ans << '\n';
	}
}
/*10 8
0110000110
3 3
1 10
4 4
1 8
1 2
9 10
2 10
3 9*/
// 1 + 2 + 4 + 8 + 15 + 30 + 60 + 120 + 240 + 480
//16 + 32 + 64 + 128 + 256 + 512


#include <cstring>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length()+1);
    vector<long long> p(s.length()+1);
    v[0]=0;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='1'){
            v[i+1]=v[i]+1;
        }else{
            v[i+1]=v[i];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        z = v[y+1]-v[x];
        cout << (p[l]-p[l-z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i-1]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]<<1)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x-1];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include <cstring>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length()+1);
    vector<long long> p(s.length()+1);
    v[0]=0;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='1'){
            v[i+1]=v[i]+1;
        }else{
            v[i+1]=v[i];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        z = v[y+1]-v[x];
        cout << (p[l]-p[l-z]+1000000007)%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length()+1);
    vector<long long> p(s.length()+1);
    v[0]=0;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='0'){
            v[i+1]=v[i]+1;
        }else{
            v[i+1]=v[i];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y+1]-v[x];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length()+1);
    vector<long long> p(s.length()+1);
    v[0]=0;
    for(int i=1; i<s.length()+1; i++){
        if(s[i]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]<<1)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;
        l = y-x;
        z = v[y]-v[x];
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length()+1);
    vector<long long> p(s.length()+1);
    v[0]=0;
    for(int i=1; i<s.length()+1; i++){
        if(s[i-1]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]<<1)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;
        l = y-x;
        z = v[y]-v[x];
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]<<1)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x-1];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x-1];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    #ios_base::sync_with_stdio(false);
    #cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x-1];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i-1]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]<<1)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long n,q,x,y,l,z;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<long> v(s.length());
    vector<long long> p(s.length()+1);
    if(s[0]=='0'){v[0]=1;}
    for(int i=1; i<s.length(); i++){
        if(s[i]=='0'){
            v[i]=v[i-1]+1;
        }else{
            v[i]=v[i-1];
        }
    }
    p[0]=1;
    for(int i=1; i<p.size(); i++){
        p[i] = (p[i-1]*2)%1000000007;
    }
    while(q--){
        cin >> x >> y;
        x-=1;y-=1;
        l = y-x+1;
        if(x==0){
            z = v[y];
        }else{
            z = v[y]-v[x-1];
        }
        cout << (p[l]-p[z])%1000000007 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define m 1000000007
									//nestedcode

int power(int x, unsigned int y)
{
    int res = 1;      // Initialize result

    x = x % m;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % m;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % m;
    }
    return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,q,i,l,r,p,z,f,g;
	string s;
	cin>>n>>q;
	ll a[n+5],d[n+5]={0};
	cin>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=='0'){
			a[i]=1;
		}else{
			a[i]=0;
		}
	//	cout<<a[i]<<endl;
	}
	for(i=0;i<s.length();i++){
		if(i!=0){
			d[i]=d[i-1]+a[i];
		//	cout<<d[i]<<endl;
		}else{
			d[i]=a[i];
		}
	}

	for(i=0;i<q;i++){
		cin>>l>>r;;
		g=r-l+1;
		l--;
		if(l==0) l=1;
		r--;
		p=d[r]-d[l-1];

	//	cout<<p<<" ";
		f=power(2,g);
		//cout<<l<<" ";
		z=power(2,p);
		cout<<(f%m-z%m+ m)%m<<endl;
	}

}