#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBsZGIgbG9uZyBkb3VibGUKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIHN6YShhKSAoaW50KWEuc2l6ZSgpCiNkZWZpbmUgcGlyIHBhaXI8aW50LGludD4KI2RlZmluZSBwaXJsbCBwYWlyPGxsLGxsPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgbWF4biA9IDFlNSArIDU7CgppbnQgY3VyX25vZGUgPSAwOwpzdHJ1Y3QgTk9ERXsKCWxsIHZhbCA9IDA7CglpbnQgTCxSOwp9OwoKLy9zcGFyc2Ugc2VnbWVudCB0cmVlCnZlY3RvciA8Tk9ERT4gc2VnOwp2ZWN0b3IgPHBhaXI8bGwsbGw+PiByZXM7CgpsbCBzdW0obGwgbCxsbCByKXsKCWlmIChsID4gcikgcmV0dXJuIDA7CglyZXR1cm4gKHIgLSBsICsgMSkgKiAobCArIHIpLzI7Cn0KCmlubGluZSBwaXIgZ2V0cGFpciAobGwgbixsbCB4KXsKCWxsIE4gPSBuIC0gMTsKCQoJaW50IHUgPSAxLGwgPSAxLHIgPSBuOwoJd2hpbGUgKGwgPD0gcil7CgkJaW50IHcgPSAobCArIHIpLzI7CgkJaWYgKHN1bShuIC0gdyxuIC0gMSkgPj0geCl7CgkJCXUgPSB3OwoJCQlyID0gdyAtIDE7CgkJfQoJCWVsc2UgbCA9IHcgKyAxOwoJfQoJCgl4IC09IHN1bShuIC0gKHUgLSAxKSxuIC0gMSk7Cg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