#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define pqueue priority_queue
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << '(' << p.fi << ", " << p.se << ')'; }

template<typename T>
void printv(const T& v) { for(auto i : v) cerr << i << ' '; cerr << '\n'; }

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

#define N 200005
#define int ll
// #define trace(...) 42

int n, m, x[N];
pii ar[N];

main()
{
    #ifndef ONLINE_JUDGE
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
     freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";

    cin >> n >> m;
    rep(i, 0, n) {
        cin >> x[i];
        ar[i] = {x[i], i};
    }

    sort(ar, ar + n);
    // rep(i, 0, n) trace(i, ar[i]);

    while(m--) {
        int i, l; cin >> i >> l; --i;
        i = lower_bound(ar, ar + n, pii{x[i], 0}) - ar;

        bool turn = 1; //0 for left; 1 for right
        bool first = 1; //Is it the first turn

        // trace(i, l, turn);

        while(1) {
            // static int cnt = 50; assert(cnt--);
            int j;
            if(turn) {
                j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
            }
            else {
                j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
            }
            // trace(i, j, l, turn);

            if(i == j) {
                turn = !turn;
                if(turn) {
                    j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
                }
                else {
                    j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
                }
                if(i == j) {
                    cout << ar[i].se + 1 << '\n';
                    break;
                }
            }

            int len = abs(ar[i].fi - ar[j].fi);
            assert(l >= len);

            if(first || 2 * len >= l) {
                l -= len;
                i = j;
                first = 0;
                turn = !turn;
            }
            else {
                if(l / len % 2) {
                    i = j;
                    turn = !turn;
                }
                l %= len;
            }
            // trace(i, j, l, len, turn);
        }
    }

    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define pqueue priority_queue
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << '(' << p.fi << ", " << p.se << ')'; }

template<typename T>
void printv(const T& v) { for(auto i : v) cerr << i << ' '; cerr << '\n'; }

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

#define N 200005
#define int ll
// #define trace(...) 42

int n, m, x[N];
pii ar[N];

main()
{
    #ifndef ONLINE_JUDGE
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
     // freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";

    cin >> n >> m;
    rep(i, 0, n) {
        cin >> x[i];
        ar[i] = {x[i], i};
    }

    sort(ar, ar + n);

    while(m--) {
        int i, l; cin >> i >> l; --i;
        i = lower_bound(ar, ar + n, pii{x[i], 0}) - ar;

        bool turn = 1; //0 for left; 1 for right

        //To avoid handling special cases, perform the first 2 moves beforehand
        int j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
        l -= ar[j].fi - ar[i].fi;
        i = j;

        j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
        l -= ar[i].fi - ar[j].fi;
        i = j;

        while(1) {
            int j;
            if(turn) {
                j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
            }
            else {
                j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
            }

            if(i == j) {
                cout << ar[i].se + 1 << '\n';
                break;
            }

            int len = abs(ar[i].fi - ar[j].fi);
            assert(l >= len);

            if(2 * len >= l) {
                l -= len;
                i = j;
                turn = !turn;
            }
            else {
                if(l / len % 2) {
                    i = j;
                    turn = !turn;
                }
                l %= len;
            }
        }
    }

    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 2e5 + 5;

int n, m, x[N], t[N];
map <int, int> mp;

// dir = 0 => left to right
// dir = 1 => right to left

int get(int nx, int l, bool dir) {
	int nxt = upper_bound(x, x + n, nx + l) - x;
	nxt--;
	int prev = lower_bound(x, x + n, nx - l) - x;
	if(!dir) {
		if(x[nxt] == nx)
			return nx;
		int len = x[nxt] - nx;
		if(len * 2 >= l)
			return get(x[nxt], l - len, dir ^ 1);
		int h = l / len, rem = l % len;
		if(h & 1)
			return get(x[nxt], rem, dir ^ 1);
		else
			return get(nx, rem, dir);
	}
	else {
		if(x[prev] == nx)
			return nx;
		int len = nx - x[prev];
		if(len * 2 >= l)
			return get(x[prev], l - len, dir ^ 1);
		int h = l / len, rem = l % len;
		if(h & 1)
			return get(x[prev], rem, dir ^ 1);
		else
			return get(nx, rem, dir);
	}
}

int get_easy(int nx, int l, bool dir, int cur = 2) {
	if(!cur)
		return get(nx, l, dir);
	int nxt = upper_bound(x, x + n, nx + l) - x;
	nxt--;
	int prev = lower_bound(x, x + n, nx - l) - x;
	if(x[nxt] == nx && x[prev] == nx)
		return nx;
	if(!dir) {
		if(x[nxt] == nx)
			return get_easy(nx, l, dir ^ 1, cur);
		int len = x[nxt] - nx;
		return get_easy(x[nxt], l - len, dir ^ 1, cur - 1);
	}
	else {
		if(x[prev] == nx)
			return get_easy(nx, l, dir ^ 1, cur);
		int len = nx - x[prev];
		return get_easy(x[prev], l - len, dir ^ 1, cur - 1);
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		t[i] = x[i];
		mp[x[i]] = i;
	}
	sort(x, x + n);
	for (int q = 0; q < m; q++) {
		int idx, l;
		cin >> idx >> l;
		idx--;
		int nx = t[idx];
		int last = lower_bound(x, x + n, get_easy(nx, l, 0)) - x;
		cout << mp[x[last]] + 1 << "\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 1e5 + 5;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define revloop(i,n) for(int i=n-1;i>=0;i--)
#define revloop1(i,n) for(int i=n;i>=1;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ff first
#define ss second
#define print(x) printf("%.9Lf\n",x)
#define MOD 1000000007
#define MAX 100005
#define MAX6 500000
#define nw cout<<endl
#define lc 2*node+1
#define rc 2*node+2
#define PRINT(v) for(int i=0;i!=v.size();i++)cout<<v[i]<<" "
#define modInverse(x) power(x,MOD-2)
using namespace std;

int main(){

    int  T,x,y;
    T=1;

    loop1(t,T){
        int n,q;
        map<int,int> pos;
        cin>>n>>q;
        vi v;
        loop1(i,n){
            cin>>x;v.pb(x);pos[x]=i;
        }
        sort(v.begin(),v.end());
        loop1(i,q){
            cin>>x>>y;x--;
            int idx=lower_bound(v.begin(),v.end(),v[x]+y)-v.begin();
            if(idx>n-1 || v[idx]>v[x]+y)idx--;
            int len=v[idx]-v[x];
            int div=y/len;
            int target=y%len;

            if(div%2){

                idx=lower_bound(v.begin(),v.end(),v[idx]-target)-v.begin();

                cout<<pos[v[idx]]<<endl;

            }
            else{
                idx=lower_bound(v.begin(),v.end(),v[x]+target)-v.begin();

                if(idx>n-1 || v[idx]>v[x]+target)idx--;

                cout<<pos[v[idx]]<<endl;
            }
        }
    }

}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<lint,lint> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

lint readL(){
  lint res;
#ifdef ONLINE_JUDGE
  scanf("%I64d",&res);
#else
  scanf("%lld",&res);
#endif
  return res;
}
void printL(lint res){
#ifdef ONLINE_JUDGE
  printf("%I64d",res);
#else
  printf("%lld",res);
#endif
}

//const int INF=5e8;

int n,m;
pi ar[200005];

int getR(int s,lint l){
  int lb=s,ub=n;
  while(ub-lb>1){
    int md=(lb+ub)>>1;
    if(ar[md].fr-ar[s].fr>l) ub=md;
    else lb=md;
  }
  return lb;
}

int getL(int s,lint l){
  int lb=-1,ub=s;
  while(ub-lb>1){
    int md=(lb+ub)>>1;
    if(ar[s].fr-ar[md].fr>l) lb=md;
    else ub=md;
  }
  return ub;
}

int conv[200005];
int main(){
  cin>>n>>m;
  REP(i,n){
    int a;scanf("%d",&a);
    ar[i].fr=a;
    ar[i].sc=i;
  }
  sort(ar,ar+n);

  REP(i,n) conv[ar[i].sc]=i;

  REP(hoge,m){
    int s,l_;
    scanf("%d%d",&s,&l_);--s;
    s=conv[s];

    lint l=l_;

    int t1=getR(s,l);
    l-=ar[t1].fr-ar[s].fr;
    int t2=getL(t1,l);
    l-=ar[t1].fr-ar[t2].fr;
    s=t2;

    while(1){
      int pivR=getR(s,l);
      lint l2=l-(ar[pivR].fr-ar[s].fr);
      int pivL=getL(pivR,l2);

      if(pivR==s) break;
      if(pivL==pivR){
        s=pivR;
        break;
      }

      if(pivL==s){
        lint length=(ar[pivR].fr-ar[s].fr)*2;
        l%=length;
      }else{
        s=pivL;
        l=l2-(ar[pivR].fr-ar[pivL].fr);
      }
    }

    printf("%d\n",(int)(ar[s].sc+1));
  }

  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define revloop(i,n) for(int i=n-1;i>=0;i--)
#define revloop1(i,n) for(int i=n;i>=1;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ff first
#define ss second
#define print(x) printf("%.9Lf\n",x)
#define MOD 1000000007
#define MAX 100005
#define MAX6 500000
#define nw cout<<endl
#define lc 2*node+1
#define rc 2*node+2
#define PRINT(v) for(int i=0;i!=v.size();i++)cout<<v[i]<<" "
#define modInverse(x) power(x,MOD-2)
using namespace std;

int main(){

    int  T,x,y;
    T=1;

    loop1(t,T){
        int n,q;
        map<int,int> pos;
        cin>>n>>q;
        vi v;
        loop1(i,n){
            cin>>x;v.pb(x);pos[x]=i;
        }
        sort(v.begin(),v.end());
        loop1(i,q){
            cin>>x>>y;x--;
            int idx=lower_bound(v.begin(),v.end(),v[x]+y)-v.begin();
            if(idx>n-1 || v[idx]>v[x]+y)idx--;
            int len=v[idx]-v[x];
            int div=y/len;
            int target=y%len;
            if(div%2){

                idx=lower_bound(v.begin(),v.end(),v[idx]-target)-v.begin();

                cout<<pos[v[idx]]<<endl;

            }
            else{
                idx=lower_bound(v.begin(),v.end(),v[x]+target)-v.begin();

                if(idx>n-1 || v[idx]>v[x]+y)idx--;

                cout<<pos[v[idx]]<<endl;
            }
        }
    }

}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define revloop(i,n) for(int i=n-1;i>=0;i--)
#define revloop1(i,n) for(int i=n;i>=1;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ff first
#define ss second
#define print(x) printf("%.9Lf\n",x)
#define MOD 1000000007
#define MAX 100005
#define MAX6 500000
#define nw cout<<endl
#define lc 2*node+1
#define rc 2*node+2
#define PRINT(v) for(int i=0;i!=v.size();i++)cout<<v[i]<<" "
#define modInverse(x) power(x,MOD-2)
using namespace std;

int main(){

    int  T,x,y;
    T=1;

    loop1(t,T){
        int n,q;
        map<int,int> pos;
        cin>>n>>q;
        vi v;
        loop1(i,n){
            cin>>x;v.pb(x);pos[x]=i;
        }
        sort(v.begin(),v.end());
        loop1(i,q){
            cin>>x>>y;
            int idx=lower_bound(v.begin(),v.end(),x+y)-v.begin();
            if(idx>n-1 || v[idx]>x+y)idx--;
            int len=v[idx]-x;
            int div=y/len;
            int target=y%len;
            if(div%2){

                idx=lower_bound(v.begin(),v.end(),v[idx]-target)-v.begin();
                cout<<pos[v[idx]]<<endl;

            }
            else{
                idx=lower_bound(v.begin(),v.end(),x+target)-v.begin();
                if(idx>n-1 || v[idx]>x+y)idx--;
                cout<<pos[v[idx]]<<endl;
            }
        }
    }

}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
int a[200000];
int num, len;
int now, l, r;

int bp_lower(int x, int l, int r)
{
    if (l==r) return l;
    int z=(l+r+1)/2;
    if (a[z]>x) return bp_lower(x,l,z-1);
    return bp_lower(x,z,r);
}

int bp_upper(int x, int l, int r)
{
    if (l==r) return l;
    int z=(l+r)/2;
    if (a[z]<x) return bp_upper(x,z+1,r);
    return bp_upper(x,l,z);
}

void main()
{
    scanf("%d%d",&n,&m);
    For(i,0,n) scanf("%d",a+i);
    For(i,0,m) {
        scanf("%d%d",&num,&len);
        int now2, now3=num-1;
        do {
        now=now3; l=0; r=n-1;

        if (now==l) len%=(2*(a[r]-a[l]));

        now2 = bp_lower(a[now]+len, now, r);
        len -= a[now2] - a[now];
        r = min(now2, r);

        now3 = bp_upper(a[now2]-len, l, now2);
        len -= a[now2] - a[now3];
        l = max(now3, l);

        } while ((now != now2) || (now2 != now3));
        cout<<now+1<<"\n";
    }
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
pair<int, int> a[200000];
map<int, int> FD;
int num, len;
int now, l, r;

int bp_lower(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r+1)/2;
	if (a[z].X>x) return bp_lower(x,l,z-1);
	return bp_lower(x,z,r);
}

int bp_upper(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r)/2;
	if (a[z].X<x) return bp_upper(x,z+1,r);
	return bp_upper(x,l,z);
}

void main()
{
	scanf("%d%d",&n,&m);
	For(i,0,n) {scanf("%d",&a[i].X); a[i].Y=i+1; }
	sort(a,a+n);
	For(i,0,n) FD[a[i].Y]=i;
	//n=100000; m=n;
	//For(i,0,n) a[i] = -100000000 + 10000*i;
	For(i,0,m) {
		scanf("%d%d",&num,&len);
		//num=i; len=1000000000;
		int now2;
		now = FD[num];
		do {
		l=0; r=n-1;

		now2 = bp_lower(a[now].X+len, now, r);
		len -= a[now2].X - a[now].X;
		r = now2;
		if (l!=r) len%=(2*(a[r].X-a[l].X));

		now = bp_upper(a[now2].X-len, l, now2);
		len -= a[now2].X - a[now].X;
		l = now;
		if (l!=r) len%=(2*(a[r].X-a[l].X));

		} while (l!=r);
		cout<<a[now].Y<<"\n";
	}
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
pair<int, int> a[200000];
map<int, int> FD;
int num, len;
int now, l, r;

int bp_lower(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r+1)/2;
	if (a[z].X>x) return bp_lower(x,l,z-1);
	return bp_lower(x,z,r);
}

int bp_upper(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r)/2;
	if (a[z].X<x) return bp_upper(x,z+1,r);
	return bp_upper(x,l,z);
}

void main()
{
	scanf("%d%d",&n,&m);
	For(i,0,n) {scanf("%d",&a[i].X); a[i].Y=i+1; }
	sort(a,a+n);
	For(i,0,n) FD[a[i].Y]=i;
	//n=100000; m=n;
	//For(i,0,n) a[i] = -100000000 + 10000*i;
	For(i,0,m) {
		scanf("%d%d",&num,&len);
		//num=i; len=1000000000;
		int now2;
		now = FD[num];
		do {
		l=0; r=n-1;

		now2 = bp_lower(a[now].X+len, now, r);
		len -= a[now2].X - a[now].X;
		r = now2;
		if (l!=r) len%=(2LL*(a[r].X-a[l].X));

		now = bp_upper(a[now2].X-len, l, now2);
		len -= a[now2].X - a[now].X;
		l = now;
		if (l!=r) len%=(2LL*(a[r].X-a[l].X));

		} while (l!=r);
		cout<<a[now].Y<<"\n";
	}
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
int a[200000];
int num, len;
int now, l, r;

int bp_lower(int x, int l, int r)
{
    if (l==r) return l;
    int z=(l+r+1)/2;
    if (a[z]>x) return bp_lower(x,l,z-1);
    return bp_lower(x,z,r);
}

int bp_upper(int x, int l, int r)
{
    if (l==r) return l;
    int z=(l+r)/2;
    if (a[z]<x) return bp_upper(x,z+1,r);
    return bp_upper(x,l,z);
}

void main()
{
    scanf("%d%d",&n,&m);
    For(i,0,n) scanf("%d",a+i);
    For(i,0,m) {
        scanf("%d%d",&num,&len);
        int now2;
        now = num-1;
        do {
        l=0; r=n-1;

        now2 = bp_lower(a[now]+len, now, r);
        len -= a[now2] - a[now];
        r = now2;
        if (l!=r) len%=(2*(a[r]-a[l]));

        now = bp_upper(a[now2]-len, l, now2);
        len -= a[now2] - a[now];
        l = now;
        if (l!=r) len%=(2*(a[r]-a[l]));

        } while ((l!=r));
        cout<<now+1<<"\n";
    }
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 2000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, m;
int a[200000];
int num, len;
int now, l, r;

int bp_lower(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r+1)/2;
	if (a[z]>x) return bp_lower(x,l,z-1);
	return bp_lower(x,z,r);
}

int bp_upper(int x, int l, int r)
{
	if (l==r) return l;
	int z=(l+r)/2;
	if (a[z]<x) return bp_upper(x,z+1,r);
	return bp_upper(x,l,z);
}

void main()
{
	scanf("%d%d",&n,&m);
	For(i,0,n) scanf("%d",a+i);
	sort(a,a+n);
	//n=100000; m=n;
	//For(i,0,n) a[i] = -100000000 + 10000*i;
	For(i,0,m) {
		scanf("%d%d",&num,&len);
		//num=i; len=1000000000;
		int now2;
		now = num-1;
		do {
		l=0; r=n-1;

		now2 = bp_lower(a[now]+len, now, r);
		len -= a[now2] - a[now];
		r = now2;
		if (l!=r) len%=(2*(a[r]-a[l]));

		now = bp_upper(a[now2]-len, l, now2);
		len -= a[now2] - a[now];
		l = now;
		if (l!=r) len%=(2*(a[r]-a[l]));

		} while (l!=r);
		cout<<now+1<<"\n";
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				int dx = abs(x[j] - x[i]);
				if (l / dx % 2) i = j;
				l %= dx;
			}
			prev[dir] = i;
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			if (j == i) {
				printf("%d\n", index[i] + 1);
				break;
			}
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				int dx = abs(x[j] - x[i]);
				l %= dx * 2;
			}
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			if (j == i) {
				printf("%d\n", index[i] + 1);
				break;
			}
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				int dx = abs(x[j] - x[i]);
				l %= dx * 2;
			}
			prev[dir] = i;
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			if (j == i) {
				printf("%d\n", index[i] + 1);
				break;
			}
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				if (i == j) {
					printf("%d\n", index[i] + 1);
					break;
				}
				int dx = abs(x[j] - x[i]);
				l %= (ll)dx * 2;
			}
			prev[dir] = i;
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				int dx = abs(x[j] - x[i]);
				if (l / dx % 2) {
					i = j;
					dir = 1 - dir;
				}
				l %= dx;
			}
			prev[dir] = i;
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			if (j == i) {
				printf("%d\n", index[i] + 1);
				break;
			}
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int n, m; cin >> n >> m;
	vector<i_i> p(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	sort(p.begin(), p.end());
	vector<int> x(n), index(n), rev(n);
	for (int i = 0; i < n; i++) {
		x[i] = p[i].first;
		index[i] = p[i].second;
		rev[p[i].second] = i;
	}
	while (m--) {
		int a, l; scanf("%d%d", &a, &l);
		int i = rev[a - 1], dir = 0;
		vector<int> prev(2, -1);
		for (;;) {
			if (prev[dir] == i) {
				int j = prev[1 - dir];
				int dx = abs(x[j] - x[i]);
				l %= (ll)dx * 2;
			}
			prev[dir] = i;
			int j;
			if (dir == 0)
				j = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
			else
				j = lower_bound(x.begin(), x.end(), x[i] - l) - x.begin();
			if (j == i) {
				printf("%d\n", index[i] + 1);
				break;
			}
			l -= abs(x[j] - x[i]);
			i = j;
			dir = 1 - dir;
		}
	}
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	for(int i=0;i<45;++i){
		his.push_back(cur);
		type = 1 - type;
		cur = newCur;
		if(cur == n-1){
			type = 0;
		}
		if(cur == 0){
			type = 1;
		}
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;true;){
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	for(;true;){
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(cur == n-1){
			type = 0;
		}
		if(cur == 0){
			type = 1;
		}
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	vector<int> ls;
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;moves < 1000;){
		ls.push_back(l);
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	if(moves > 1000){
		for(int i=ls.size()-1;i>=0;--i){
			printf("%d\n",ls[i]);
		}
		exit(0);
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		//printf("%d\n",solve(pos[p], l));
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	int cur = -1;
	int type = 0;
	int newCur = p;
	for(int i=0;i<45;++i){
		type = 1 - type;
		cur = newCur;
		if(cur == n-1){
			type = 0;
		}
		if(cur == 0){
			type = 1;
		}
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				break;
			}
			int cnt = l / (a[newCur] - a[cur]);
			l -= (a[newCur] - a[cur]) * cnt;
			if(cnt % 2 == 0){
				type = 1 - type;
				newCur = cur;
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				break;
			}
			int cnt = l / (a[newCur] - a[cur]);
			l -= (a[newCur] - a[cur]) * cnt;
			if(cnt % 2 == 0){
				type = 1 - type;
				newCur = cur;
			}
		}
	}
	return cur + 1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	for(;true;){
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;true;){
		++moves;
		if(moves > 1000){
			cout << "S";
			exit(0);
		}
		his.push_back(cur);
		type = 1 - type;
		cur = newCur;
		if(cur == n-1){
			type = 0;
		}
		if(cur == 0){
			type = 1;
		}
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	for(;true;){
		his.push_back(cur);
		type = 1 - type;
		cur = newCur;
		if(cur == n-1){
			type = 0;
		}
		if(cur == 0){
			type = 1;
		}
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				break;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;true;){
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				if(moves >= 100){
					for(int i=his.size()-1;i>80;--i){
						cout << his[i] << " ";
					}
					cout << endl;
					bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
					cout << his[his.size()-2] << " " << newCur << " " << (v);
					exit(0);
				}
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				if(moves >= 100){
					for(int i=his.size()-1;i>80;--i){
						cout << his[i] << " ";
					}
					cout << endl;
					bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
					cout << his[his.size()-2] << " " << newCur << " " << (v);
					exit(0);
				}
				l -= (a[cur] - a[newCur]);
			}else{

				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		//printf("%d\n",solve(pos[p], l));
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	vector<int> ls;
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;moves < 100;){
		ls.push_back(l);
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	if(moves > 100){
		for(int i=ls.size()-1;i>=0;--i){
			printf("%d\n",ls[i]);
		}
		exit(0);
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		//printf("%d\n",solve(pos[p], l));
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;true;){
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				l -= (a[newCur] - a[cur]);
			}else{
				if(moves > 100){
					cout << his[his.size()-2] << " " << newCur;
					exit(0);
				}
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				l -= (a[cur] - a[newCur]);
			}else{
				if(moves > 100){
					cout << his[his.size()-2] << " " << newCur;
					exit(0);
				}
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		//printf("%d\n",solve(pos[p], l));
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	//int moves = 0;
	for(;true;){
		//++moves;
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		his.push_back(cur);
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				//if(moves >= 100){
				//	for(int i=his.size()-1;i>80;--i){
				//		cout << his[i] << " ";
				//	}
				//	cout << endl;
				//	bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
				//	cout << his[his.size()-2] << " " << newCur << " " << (v);
				//	exit(0);
				//}
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				//if(moves >= 100){
				//	for(int i=his.size()-1;i>80;--i){
				//		cout << his[i] << " ";
				//	}
				//	cout << endl;
				//	bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
				//	cout << his[his.size()-2] << " " << newCur << " " << (v);
				//	exit(0);
				//}
				l -= (a[cur] - a[newCur]);
			}else{

				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	//vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		printf("%d\n",solve(pos[p], l));
		//r.push_back(solve(pos[p], l));
	}
	//for(int i=0;i<r.size();++i){
	//	printf("%d\n",r[i]);
	//}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	vector<int> ls;
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;moves < 100;){
		ls.push_back(cur);
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	if(moves >= 100){
		for(int i=ls.size()-1;i>=0;--i){
			printf("%d\n",ls[i]);
		}
		exit(0);
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	vector<int> ls;
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;moves < 100;){
		ls.push_back(l);
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if(his.size() < 2 || his[his.size()-2] != newCur){
				l -= (a[cur] - a[newCur]);
			}else{
				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	if(moves >= 100){
		for(int i=ls.size()-1;i>=0;--i){
			printf("%d\n",ls[i]);
		}
		exit(0);
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int const N = 2e5 + 456;

int a[N], n, m, p, l, pos[N];
vector<pair<int,int>> b;
vector<int> his;

int bpR(int p, int len){
	int l = p-1;
	int r = n;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] + len >= a[m]){
			l = m;
		}else{
			r = m;
		}
	}
	return l;
}

int bpL(int p, int len){
	int l = -1;
	int r = p+1;
	while(r-l>1){
		int m = (r+l)/2;
		if(a[p] - len <= a[m]){
			r = m;
		}else{
			l = m;
		}
	}
	return r;
}

int solve(int p, int l){
	his.clear();
	int cur = -1;
	int type = 0;
	int newCur = p;
	int moves = 0;
	for(;true;){
		++moves;
		his.push_back(cur);
		if(his.size() > 10 && his[his.size()-1] == his[his.size()-2] && his[his.size()-3] == his[his.size()-4] && his[his.size()-1] == his[his.size()-4]){
			break;
		}
		type = 1 - type;
		cur = newCur;
		if(type == 1){
			newCur = bpR(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				if(moves >= 100){
					bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
					cout << his[his.size()-2] << " " << newCur << " " << (v);
					exit(0);;
				}
				l -= (a[newCur] - a[cur]);
			}else{
				int cnt = l / (a[newCur] - a[cur]);
				l -= (a[newCur] - a[cur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}else{
			newCur = bpL(cur, l);
			if(newCur == cur){
				continue;
			}
			if((his.size() < 2) || (his[his.size()-2] != newCur)){
				if(moves >= 100){
					bool v = ((his.size() < 2) || (his[his.size()-2] != newCur));
					cout << his[his.size()-2] << " " << newCur << " " << (v);
					exit(0);
				}
				l -= (a[cur] - a[newCur]);
			}else{

				int cnt = l / (a[cur] - a[newCur]);
				l -= (a[cur] - a[newCur]) * cnt;
				if(cnt % 2 == 0){
					type = 1 - type;
					newCur = cur;
				}
			}
		}
	}
	return b[cur].second+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
		b.push_back(make_pair(a[i], i));
	}
	sort(a, a+n);
	sort(b.begin(), b.end());
	for(int i=0;i<b.size();++i){
		pos[b[i].second] = i;
	}
	vector<int> r;
	for(int i=0;i<m;++i){
		scanf("%d%d",&p,&l);
		--p;
		//printf("%d\n",solve(pos[p], l));
		r.push_back(solve(pos[p], l));
	}
	for(int i=0;i<r.size();++i){
		printf("%d\n",r[i]);
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:64000000")
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>

using namespace std;

vector<pair<int, int> > a;
int rev[200005];
int n, m;

vector<pair<int, int> > s;

int model(int p, int l, int d)
{
    if (l == 0)
        return p;
    int id = lower_bound(a.begin(), a.end(), make_pair(a[p].first + l * d, -1)) - a.begin();
    if (id == n)
        id--;
    if (a[p].first + l * d == a[id].first)
        return id;
    if (l < abs(a[id].first - a[p].first))
        id--;
    if (p != id)
    {
        if (!s.empty() && s[s.size() - 1].first == id && s[s.size() - 1].second == p)
        {
            int div = l / abs(a[p].first - a[id].first);
            int mod = l % abs(a[p].first - a[id].first);
            return model((div & 1) ? id : p, mod, (div & 1) ? d * -1 : d);
        }
        s.push_back(make_pair(p, id));
        return model(id, l - abs(a[p].first - a[id].first), d * -1);
    }

    d *= -1;
    id = lower_bound(a.begin(), a.end(), make_pair(a[p].first + l * d, -1)) - a.begin();
    if (id == n)
        id--;

    if (a[p].first + l * d == a[id].first)
        return id;
    if (l < abs(a[id].first - a[p].first))
        id--;

    if (id == p)
        return p;
    s.push_back(make_pair(p, id));
    return model(id, l - abs(a[p].first - a[id].first), d * -1);
}

int main()
{
    scanf("%d%d", &n, &m);
    a.resize(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++)
        rev[a[i].second] = i;

    for (int i = 0; i < m; i++)
    {
        int p, l;
        scanf("%d%d", &p, &l);
        p--;
        p = rev[p];
        s.clear();
        int res = model(p, l, 1);
        printf("%d\n", a[res].second + 1);
    }

    return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs, map<int, int>& x_ind) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a + l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], right - xs[t2], xs, x_ind);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  int used = xs[t2] - a + xs[t2] - xs[t];
  if (used * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs, x_ind);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs, x_ind);
}

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs, x_ind);
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs, map<int, int>& x_ind) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], right - xs[t2], xs, x_ind);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  int used = xs[t2] - a + xs[t2] - xs[t];
  if (used * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs, x_ind);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs, x_ind);
}

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs, x_ind);
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs, map<int, int>& x_ind) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (t == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], right - xs[t2], xs, x_ind);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  int used = xs[t2] - a + xs[t2] - xs[t];
  if (used * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs, x_ind);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs, x_ind);
}

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs, x_ind);
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a + l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], xs[t2] - right, xs);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  ll used = ll(xs[t2] - a) + ll(xs[t2] - xs[t]);
  if (ll(used) * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs);
}

int GetLastColSlow(int a, int l, const vi& xs) {
  set<pii> was;
  was.insert(MP(a, l));
  int cur_x = a;
  int cur_l = l;
  while (true) {
    if (cur_l == 0) {
      return cur_x;
    }
    if (cur_l > 0) {
      int last_leq = -1;
      while (last_leq + 1 < xs.size() && xs[last_leq + 1] <= cur_x + cur_l) {
        ++last_leq;
      }
      cur_l -= xs[last_leq] - cur_x;
      cur_l = -cur_l;
      cur_x = xs[last_leq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    } else {
      cur_l = -cur_l;
      int first_geq = 0;
      while (first_geq < xs.size() && xs[first_geq] < cur_x - cur_l) {
        ++first_geq;
      }
      cur_l -= cur_x - xs[first_geq];
      cur_x = xs[first_geq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    }
  }
  return -2000000000;
}

int main() {
  /*while (true) {
    int n = rand() % 100 + 1;
    cerr << n << endl;
    vi x(n);
    for (int i = 0; i < n; ++i) {
      x[i] = rand() % 201 - 100;
    }
    vi xs = x;
    sort(xs.begin(), xs.end());
    int a = rand() % n;
    int l = rand() % 200;
    int res1 = GetLastCol(x[a], l, xs);
    int res2 = GetLastColSlow(x[a], l, xs);
    if (res1 != res2) {
      cerr << "Wrong answer: " << res1 << ' ' << res2 << endl;
      for (int i = 0; i < n; ++i) {
        cerr << x[i] << ' ';
      }
      cerr << endl;
      cerr << x[a] << ' ' << l << endl;
      break;
    } else {
      cerr << "OK " << res1 << endl;
    }
  }*/
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs);
    if (!x_ind.count(last_x)) {
      abort();
    }
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs, map<int, int>& x_ind) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs, x_ind);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], right - xs[t2], xs, x_ind);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  int used = xs[t2] - a + xs[t2] - xs[t];
  if (used * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs, x_ind);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs, x_ind);
}

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs, x_ind);
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a + l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], xs[t2] - right, xs);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  ll used = ll(xs[t2] - a) + ll(xs[t2] - xs[t]);
  if (ll(used) * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs);
}

int GetLastColSlow(int a, int l, const vi& xs) {
  set<pii> was;
  was.insert(MP(a, l));
  int cur_x = a;
  int cur_l = l;
  while (true) {
    if (cur_l == 0) {
      return cur_x;
    }
    if (cur_l > 0) {
      int last_leq = -1;
      while (last_leq + 1 < xs.size() && xs[last_leq + 1] <= cur_x + cur_l) {
        ++last_leq;
      }
      cur_l -= xs[last_leq] - cur_x;
      cur_l = -cur_l;
      cur_x = xs[last_leq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    } else {
      cur_l = -cur_l;
      int first_geq = 0;
      while (first_geq < xs.size() && xs[first_geq] < cur_x - cur_l) {
        ++first_geq;
      }
      cur_l -= cur_x - xs[first_geq];
      cur_x = xs[first_geq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    }
  }
  return -2000000000;
}

int main() {
  /*while (true) {
    int n = rand() % 100 + 1;
    cerr << n << endl;
    vi x(n);
    for (int i = 0; i < n; ++i) {
      x[i] = rand() % 201 - 100;
    }
    vi xs = x;
    sort(xs.begin(), xs.end());
    int a = rand() % n;
    int l = rand() % 200;
    int res1 = GetLastCol(x[a], l, xs);
    int res2 = GetLastColSlow(x[a], l, xs);
    if (res1 != res2) {
      cerr << "Wrong answer: " << res1 << ' ' << res2 << endl;
      for (int i = 0; i < n; ++i) {
        cerr << x[i] << ' ';
      }
      cerr << endl;
      cerr << x[a] << ' ' << l << endl;
      break;
    } else {
      cerr << "OK " << res1 << endl;
    }
  }*/
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < x.size(); ++i) {
    x_ind[x[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastCol(x[a], l, xs);
    if (!x_ind.count(last_x)) {
      abort();
    }
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "D"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int GetLastCol(int a, int l, const vi& xs) {
  if (l == 0) {
    return a;
  }
  if (l < 0) {
    int left = a + l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  int right = a + l;
  int t2 = upper_bound(xs.begin(), xs.end(), right) - xs.begin();
  --t2;
  if (xs[t2] == a) {
    int left = a - l;
    int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
    if (xs[t] == a) {
      return a;
    }
    return GetLastCol(xs[t], xs[t] - left, xs);
  }
  if (right - xs[t2] <= l / 2) {
    return GetLastCol(xs[t2], xs[t2] - right, xs);
  }
  int left = xs[t2] - (l - (xs[t2] - a));
  int t = lower_bound(xs.begin(), xs.end(), left) - xs.begin();
  ll used = ll(xs[t2] - a) + ll(xs[t2] - xs[t]);
  if (ll(used) * 2 >= l) {
    return GetLastCol(xs[t], l - used, xs);
  }
  if (xs[t2] == xs[t]) {
    return xs[t];
  }
  l -= used;
  l = l % (ll(2) * (xs[t2] - xs[t]));
  return GetLastCol(xs[t], l, xs);
}

int GetLastColSlow(int a, int l, const vi& xs) {
  set<pii> was;
  was.insert(MP(a, l));
  int cur_x = a;
  int cur_l = l;
  while (true) {
    if (cur_l == 0) {
      return cur_x;
    }
    if (cur_l > 0) {
      int last_leq = -1;
      while (last_leq + 1 < xs.size() && xs[last_leq + 1] <= cur_x + cur_l) {
        ++last_leq;
      }
      cur_l -= xs[last_leq] - cur_x;
      cur_l = -cur_l;
      cur_x = xs[last_leq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    } else {
      cur_l = -cur_l;
      int first_geq = 0;
      while (first_geq < xs.size() && xs[first_geq] < cur_x - cur_l) {
        ++first_geq;
      }
      cur_l -= cur_x - xs[first_geq];
      cur_x = xs[first_geq];
      if (was.count(MP(cur_x, cur_l))) {
        return cur_x;
      }
      was.insert(MP(cur_x, cur_l));
    }
  }
  return -2000000000;
}

int main() {
  /*while (true) {
    int n = rand() % 100 + 1;
    cerr << n << endl;
    vi x(n);
    for (int i = 0; i < n; ++i) {
      x[i] = rand() % 201 - 100;
    }
    vi xs = x;
    sort(xs.begin(), xs.end());
    int a = rand() % n;
    int l = rand() % 200;
    int res1 = GetLastCol(x[a], l, xs);
    int res2 = GetLastColSlow(x[a], l, xs);
    if (res1 != res2) {
      cerr << "Wrong answer: " << res1 << ' ' << res2 << endl;
      for (int i = 0; i < n; ++i) {
        cerr << x[i] << ' ';
      }
      cerr << endl;
      cerr << x[a] << ' ' << l << endl;
      break;
    } else {
      cerr << "OK " << res1 << endl;
    }
  }*/
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, m;
  cin >> n >> m;
  vi x(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x[i]);
  }
  vi xs = x;
  sort(xs.begin(), xs.end());
  map<int, int> x_ind;
  for (int i = 0; i < xs.size(); ++i) {
    x_ind[xs[i]] = i;
  }
  for (int query = 0; query < m; ++query) {
    int a, l;
    scanf("%d%d", &a, &l);
    --a;
    int last_x = GetLastColSlow(x[a], l, xs);
    if (!x_ind.count(last_x)) {
      abort();
    }
    int last_col = x_ind[last_x];
    printf("%d\n", last_col + 1);
  }
  //cerr << "Remove freopen!!!" << endl;
  return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;

int n,m;
vector<int> x;
map<int,int> rx, lx;

inline int result(int a, int l) {
    if (n==1) return 1;
//  cout << a << "\n";
    int b;
    map<int,int>::iterator it = rx.upper_bound(x[a]+l);
    it--;
    b = it->second;
//  cout << b << "\n";
    l -= x[b] - x[a];
    bool rd = false;
    while (true) {
        if (rd) it = rx.upper_bound(x[b]+l);
        else it = lx.upper_bound(-x[b]+l);
        it--;
        int c = it->second;
//      cout << c << "\n";
        if (c == b) return b;
        if (c == a) {
            int t = abs(x[a] - x[b]);
            int d = l / t;
            l %= t;
            if (d & 1) {
                swap(a,b);
                rd = !rd;
            }
        }
        else {
            l -= abs(x[c]-x[b]);
            a = b; b = c;
            rd = !rd;
        }
    }
    return 0;
}

int main() {
    cin >> n >> m;
    x.resize(n+1);
    for(int i =1; i <= n;i++) {
        cin >> x[i];
        rx.insert(pii(x[i],i));
        lx.insert(pii(-x[i],i));
    }

    for(int i=0; i<m;i++) {
        int a,l;
        cin >> a >> l;
        cout << result(a,l) << "\n";
    }

    return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;

int n,m;
vector<int> x;
map<int,int> rx, lx;

inline int result(int a, int l) {
    if (n==1) return 1;
//  cout << a << "\n";
    int b;
    map<int,int>::iterator it = rx.upper_bound(x[a]+l);
    it--;
    b = it->second;
//  cout << b << "\n";
    l -= x[b] - x[a];
    bool rd = false;
    while (true) {
        if (rd) it = rx.upper_bound(x[b]+l);
        else it = lx.upper_bound(-x[b]+l);
        it--;
        int c = it->second;
//      cout << c << "\n";
        if (c == b) return b;
        if (c == a) {
            int t = abs(x[a] - x[b]);
            int d = t / l;
            l %= t;
            if (d & 1) {
                swap(a,b);
                rd = !rd;
            }
        }
        else {
            l -= abs(x[c]-x[b]);
            a = b; b = c;
            rd != rd;
        }
    }
    return 0;
}

int main() {
    cin >> n >> m;
    x.resize(n+1);
    for(int i =1; i <= n;i++) {
        cin >> x[i];
        rx.insert(pii(x[i],i));
        lx.insert(pii(-x[i],i));
    }

    for(int i=0; i<m;i++) {
        int a,l;
        cin >> a >> l;
        cout << result(a,l) << "\n";
    }

    return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;

int n,m;
vector<int> x;
map<int,int> rx, lx;

inline int result(int a, int l) {
    if (n==1) return 1;
//  cout << a << "\n";
    int b;
    map<int,int>::iterator it = rx.upper_bound(x[a]+l);
    it--;
    b = it->second;
//  cout << b << "\n";
    l -= x[b] - x[a];
    bool rd = false;
    while (true) {
        if (rd) it = rx.upper_bound(x[b]+l);
        else it = lx.upper_bound(-x[b]+l);
        it--;
        int c = it->second;
//      cout << c << "\n";
        if (c == b) return b;
        if (c == a) {
            int t = abs(x[a] - x[b]);
            int d = l / t;
            l %= t;
            if (d & 1) {
                swap(a,b);
                rd = !rd;
            }
        }
        else {
            l -= abs(x[c]-x[b]);
            a = b; b = c;
            rd != rd;
        }
    }
    return 0;
}

int main() {
    cin >> n >> m;
    x.resize(n+1);
    for(int i =1; i <= n;i++) {
        cin >> x[i];
        rx.insert(pii(x[i],i));
        lx.insert(pii(-x[i],i));
    }

    for(int i=0; i<m;i++) {
        int a,l;
        cin >> a >> l;
        cout << result(a,l) << "\n";
    }

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define x first
#define y second

typedef long long ll;
const int MAXN = 200005;
int a[MAXN];
int ls[MAXN], rs[MAXN];
int n, m;

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

	cin >> n >> m;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i < n; i++)
		ls[i] = a[i]-a[0];
	for (int i = n - 2; 0 <= i; i--)
		rs[i] = a[n-1] - a[i];
	reverse(rs, rs + n);

	for (int i = 0; i < m; i++)
	{
		int pos, l;
		scanf("%d%d", &pos, &l);
		pos--;
		int prevpos = -1;
		bool rmove = true;
		int lhigh = n;
		int rhigh = n;

		if (ls[n - 1] < l + ls[pos])
		{
			l -= (ls[n - 1] - ls[pos]);
			pos = n - 1;
			rmove = false;
			int d = l / ls[n - 1];
			if (d>0)
			{
				l = l % ls[n - 1];
				if (d & 1)
				{
					pos = 0;
					rmove = true;
				}
				else
				{
					pos = n - 1;
					rmove = false;
				}
			}
		}
		//ls[n-1]%;

		while (prevpos != pos)
		{
			prevpos = pos;
			if (rmove)
			{
				int lsv = ls[pos] + l;
				pos = upper_bound(ls + pos, ls + lhigh, lsv) - ls - 1;
				lhigh = pos+1;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			else
			{
				int rpos = (n - 1) - pos;
				int rsv = rs[rpos] + l;
				rpos = upper_bound(rs + rpos, rs + rhigh, rsv) - rs - 1;
				rhigh = rpos+1;
				pos = (n - 1) - rpos;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			rmove = !rmove;
		}
		cout << pos + 1 << endl;
	}

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define x first
#define y second

typedef long long ll;
const int MAXN = 200005;
int a[MAXN];
int ls[MAXN], rs[MAXN];
int n, m;

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

	cin >> n >> m;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i < n; i++)
		ls[i] = a[i]-a[0];
	for (int i = n - 2; 0 <= i; i--)
		rs[i] = a[n-1] - a[i];
	reverse(rs, rs + n);

	for (int i = 0; i < m; i++)
	{
		int pos, l;
		scanf("%d%d", &pos, &l);
		pos--;
		int prevpos = -1;
		bool rmove = true;
		int low = 0;
		int high = n;
		while (prevpos != pos)
		{
			prevpos = pos;
			if (rmove)
			{
				int lsv = ls[pos] + l;
				pos = upper_bound(ls + pos, ls + high, lsv) - ls - 1;
				high = pos;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			else
			{
				int rpos = (n - 1) - pos;
				int rsv = rs[rpos] + l;
				rpos = upper_bound(rs + rpos, rs + (n - low), rsv) - rs - 1;
				pos = (n - 1) - rpos;
				low = pos;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			rmove = !rmove;
		}
		cout << pos + 1 << endl;
	}

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define x first
#define y second

typedef long long ll;
const int MAXN = 200005;
pair<int, int> a[MAXN];
int ainv[MAXN];
int ls[MAXN], rs[MAXN];
int n, m;

int bcomp(const int &l, const int &r)
{
	return l > r;
}

int main()
{
	ios::sync_with_stdio(false);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i].x);
		a[i].y = i + 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		ainv[a[i].y] = i;
	for (int i = 1; i < n; i++)
		ls[i] = a[i].x-a[0].x;
	for (int i = n - 2; 0 <= i; i--)
		rs[i] = a[n-1].x - a[i].x;
	//reverse(rs, rs + n);

	for (int i = 0; i < m; i++)
	{
		int pos, l;
		scanf("%d%d", &pos, &l);
		pos = ainv[pos];
		int prevpos = -1;
		bool rmove = (pos!=n-1);
		int low		= 0;
		int	high	= n;

		while (prevpos != pos)
		{
			prevpos = pos;
			if (rmove)
			{
				int lsv = ls[pos] + l;
				pos = upper_bound(ls+low, ls + high, lsv) - ls - 1;
				high = pos + 1;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			else
			{
				int rsv = rs[pos] + l;
				pos = lower_bound(rs+low, rs+high, rsv, bcomp) - rs;
				low = pos;
				l = l - abs(rs[pos] - rs[prevpos]);
			}
			rmove = !rmove;

			//int diff = ls[high-1] - ls[low];
			//if (diff == 0)
			//	continue;
			//int d = l / diff;
			//if (d > 0)
			//{
			//	l = l % diff;
			//	if (d & 1)
			//	{
			//		if (pos + 1 == high)
			//		{
			//			pos = low;
			//			rmove = true;
			//		}
			//		else
			//		{
			//			pos = high-1;
			//			rmove = false;
			//		}
			//	};
			//}

		}
		cout << a[pos].y << endl;
	}

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define x first
#define y second
typedef long long ll;
const int MAXN = 200005;
pair<int, int> a[MAXN];
int ainv[MAXN];

ll ls[MAXN], rs[MAXN];
int n, m;

int bcomp(const ll &l, const ll &r)
{
	return l > r;
}

int main()
{
	ios::sync_with_stdio(false);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i].x);
		a[i].y = i + 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		ainv[a[i].y] = i;
	for (int i = 1; i < n; i++)
		ls[i] = a[i].x-a[0].x;
	for (int i = n - 2; 0 <= i; i--)
		rs[i] = a[n-1].x - a[i].x;
	//reverse(rs, rs + n);

	for (int i = 0; i < m; i++)
	{
		int pos, l;
		scanf("%d%d", &pos, &l);
		pos = ainv[pos];
		int prevpos = -1;
		bool rmove = (pos!=n-1);
		int low		= 0;
		int	high	= n;

		while (prevpos != pos)
		{
			prevpos = pos;
			if (rmove)
			{
				ll lsv = ls[pos] + (ll)l;
				pos = upper_bound(ls+low, ls + high, lsv) - ls - 1;
				high = pos + 1;
				l = l - abs(ls[pos] - ls[prevpos]);
			}
			else
			{
				ll rsv = rs[pos] + (ll)l;
				pos = lower_bound(rs+low, rs+high, rsv, bcomp) - rs;
				low = pos;
				l = l - abs(rs[pos] - rs[prevpos]);
			}
			rmove = !rmove;

			ll diff = ls[high-1] - ls[low];
			if (diff == 0)
				continue;
			ll d = (ll)1 / diff;
			if (d > 0)
			{
				l = l % diff;
				if (d & 1)
				{
					if (pos + 1 == high)
					{
						pos = low;
						rmove = true;
					}
					else
					{
						pos = high-1;
						rmove = false;
					}
				};
				prevpos = -1;
			}

		}
		cout << a[pos].y << endl;
	}

}