#include<bits/stdc++.h>
using namespace std;
namespace io{
char buf[1<<20],*p1=buf,*p2=buf;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin)),p1==p2?EOF:*p1++)
int read(){
int x=0,f=0;char c=gc();
while(c< '0'||c> '9') f|=c=='-',c=gc();
while(c>='0'&&c<='9') x=x*10+(c^48),c=gc();
return f?-x:x;
}
char pbuf[1<<20],*pp=pbuf;
#define flush() (fwrite(pbuf,1,pp-pbuf,stdout),pp=pbuf)
#define pc(ch) (pp==pbuf+(1<<20)&&flush(),*pp++=(ch))
class Flush{public:~Flush(){flush();}}_;
void write(int x,char ch=0){
if(x<0) pc('-'),x=-x;
static int st[35];int top=0;
do st[top++]=x%10,x/=10;while(x);
while(top) pc(st[--top]^48);if(ch) pc(ch);
}
void putc(char ch){pc(ch);}
}
#define ll long long
int x3[2009];
unordered_map<int,pair<int,int> >mp;
int main(){
// freopen("in.in","r",stdin);
int L,q;
L=io::read();
q=io::read();
for(int i=-L;i<=L;i++)
x3[i+L]=i*i*i;
for(int i=-L;i<=L;i++)
for(int j=-L;j<=L;j++)
if(!mp.count(x3[i+L]+x3[j+L]))
mp[x3[i+L]+x3[j+L]]={i,j};
while(q--){
int x,ok=0;
x=io::read();
for(int k=-L;k<=L;k++)
if(mp.count(x-x3[k+L])){
auto p=mp[x-x3[k+L]];
io::write(k,' ');
io::write(p.first,' ');
io::write(p.second,'\n');
ok=1;break;
}
if(!ok){
io::write(L+1,' ');
io::write(L+1,' ');
io::write(L+1,'\n');
}
}
return 0;
}