//Using custom stack implementation with array
#include<stdio.h>
#define sf scanf
#define pf printf
int st[1024];
int top=0;
void push(int task)
{
st[top++] = task;
}
int pop()
{
top--;
return st[top];
}
int main()
{
int kase,t,mx=0;
sf("%d",&kase);
while(kase--)
{
int n;
sf("%d",&n);
while(n--)
{
sf("%d",&t);
push(t);
if(t>mx) mx = t;
}
pf("Ordering: ");
while(top>0)
{
pf("%d ",pop());
}
pf("\nMax: %d\n",mx);
top = 0;
memset(st,0,sizeof(st));
mx=0;
}
return 0;
}