#include<bits/stdc++.h>
#define ll long long
#define ldb long double
#define fi first
#define se second
#define sza(a) (int)a.size()
#define pir pair<int,int>
#define pirll pair<ll,ll>
using namespace std;
const int maxn = 1e5 + 5;

int cur_node = 0;
struct NODE{
	ll val = 0;
	int L,R;
};

//sparse segment tree
vector <NODE> seg;
vector <pair<ll,ll>> res;

ll sum(ll l,ll r){
	if (l > r) return 0;
	return (r - l + 1) * (l + r)/2;
}

inline pir getpair (ll n,ll x){
	ll N = n - 1;
	
	int u = 1,l = 1,r = n;
	while (l <= r){
		int w = (l + r)/2;
		if (sum(n - w,n - 1) >= x){
			u = w;
			r = w - 1;
		}
		else l = w + 1;
	}
	
	x -= sum(n - (u - 1),n - 1);
	
	int v = x + u;
	if (u > v) swap(u,v);
	return {u,v};
}

void init(ll n){
	ll T = n*(n - 1)/2;
	seg.push_back({T,0,0});
}
ll walk_on_tree(ll l,ll r,int node,ll t){
	ll val = seg[node].val;
	ll w = (l + r)/2;
	
	if (l == r) return l;
	
	//if child node is not initialized, that means no deletion operation has reached
	//initialize new node
	if (!seg[node].L){
	   seg[node].L = ++cur_node;
       seg.push_back({w - l + 1,0,0});  
	}
	if (!seg[node].R){
	 	seg[node].R = ++cur_node;
	 	seg.push_back({r - w,0,0});
	}
	//////////
	if (seg[seg[node].L].val >= t)
	  return walk_on_tree(l,w,seg[node].L,t);
	
	t -= seg[seg[node].L].val;
	return walk_on_tree(w + 1,r,seg[node].R,t);
}
void deletion(ll l,ll r,int node,ll x){
	ll val = seg[node].val;
	ll w = (l + r)/2;
	
	if (l > x || r < x) return;
	if (l == r){
		seg[node].val = 0;
		return;
	}
	//if child node is not initialized, that means no deletion operation has reached
	//initialize new node
	if (!seg[node].L){
	   seg[node].L = ++cur_node;
       seg.push_back({w - l + 1,0,0});  
	}
	if (!seg[node].R){
	 	seg[node].R = ++cur_node;
	 	seg.push_back({r - w,0,0});
	}
	//////////
	
	int L = seg[node].L,R = seg[node].R;
	
	deletion(l,w,L,x);
	deletion(w + 1,r,R,x);
	
	seg[node].val = seg[L].val + seg[R].val;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("GENTEST.inp","r",stdin);
	//freopen("GENTEST.out","w",stdout);
	ll n;int m;
	cin >> n >> m;
	init(n);
	if (n == 1) return 0;
	
	ll N = n*(n - 1);
	vector <ll> lst;
	while (m--){
		ll t;
		cin >> t;
		
		ll x = walk_on_tree(1,N,0,t);
		
		deletion(1,N,0,x);
		
		res.push_back(getpair(n,x));
	}
	
	for (pir p : res) cout << p.fi << " " << p.se << "\n";

	return 0;
}
