#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <set>
#include <deque>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <numeric>
#define Yellow_Flash \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pi 3.14159265358979323
#define el "\n"
#define ll long long
#define sp ' '
#define MAX INT_MAX
#define MIN INT_MIN
using namespace std;
using namespace __gnu_pbds;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
Yellow_Flash;
ll t;
cin >> t;
while(t--){
ll n;
cin >> n;
vector<ll> v(n), beg(n), end(n);
stack<ll> st;
map<ll,ll> ind;
for (int i=0; i<n; ++i) {
cin >> v[i];
ind[v[i]]=i;
}
for(int i=n-1; i>=0; --i){
while(!st.empty() && st.top()>v[i]) st.pop();
if(st.empty()) end[i]=ind[v[i]];
else end[i]=ind[st.top()];
st.push(v[i]);
}
for(int i=0; i<n; ++i){
while(!st.empty() && st.top()>v[i]) st.pop();
if(st.empty()) beg[i]=ind[v[i]];
else beg[i]=ind[st.top()];
st.push(v[i]);
}
ll mx=MIN;
for(int i=0; i<n; ++i){
if (beg[i]==-1 && end[i]==-1){
mx=max(n,mx);
}
else if (beg[i]==-1) {
mx=max(mx,end[i]);
}
else if (end[i]==-1) {
mx=max(mx,n-(beg[i]+1));
}
else {
mx=max(mx,end[i]-(beg[i]+1));
}
cout << beg[i] << sp << end[i] << sp << mx << el;
}
}
return 0;
}
/* Fight not to be the Winner ,but to be the last one to lose */
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4KI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+CiNpbmNsdWRlIDxpb3N0c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yAKICAgICAgICBmb3IgKGludCBpPTA7IGk8bjsgKytpKSB7CiAgICAgICAgICAgIGNpbiA+PiB2W2ldOwogICAgICAgICAgICBpbmRbdltpXV09aTsKICAgICAgICB9CiAgICAgICAgZm9yKGludCBpPW4tMTsgaT49MDsgLS1pKXsKICAgICAgICAgICAgd2hpbGUoIXN0LmVtcHR5KCkgJiYgc3QudG9wKCk+dltpXSkgc3QucG9wKCk7CiAgICAgICAgICAgIGlmKHN0LmVtcHR5KCkpIGVuZFtpXT1pbmRbdltpXV07CiAgICAgICAgICAgIGVsc2UgZW5kW2ldPWluZFtzdC50b3AoKV07CiAgICAgICAgICAgIHN0LnB1c2godltpXSk7CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaT0wOyBpPG47ICsraSl7CiAgICAgICAgICAgIHdoaWxlKCFzdC5lbXB0eSgpICYmIHN0LnRvcCgpPnZbaV0pIHN0LnBvcCgpOwogICAgICAgICAgICBpZihzdC5lbXB0eSgpKSBiZWdbaV09aW5kW3ZbaV1dOwogICAgICAgICAgICBlbHNlIGJlZ1tpXT1pbmRbc3QudG9wKCldOwogICAgICAgICAgICBzdC5wdXNoKHZbaV0pOwogICAgICAgIH0KICAgICAgICBsbCBteD1NSU47CiAgICAgICAgZm9yKGludCBpPTA7IGk8bjsgKytpKXsKICAgICAgICAgICAgaWYgKGJlZ1tpXT09LTEgJiYgZW5kW2ldPT0tMSl7CiAgICAgICAgICAgICAgICBteD1tYXgobixteCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoYmVnW2ldPT0tMSkgewogICAgICAgICAgICAgICAgbXg9bWF4KG14LGVuZFtpXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoZW5kW2ldPT0tMSkgewogICAgICAgICAgICAgICAgbXg9bWF4KG14LG4tKGJlZ1tpXSsxKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBteD1tYXgobXgsZW5kW2ldLShiZWdbaV0rMSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvdXQgPDwgYmVnW2ldIDw8IHNwIDw8IGVuZFtpXSA8PCBzcCA8PCBteCA8PCBlbDsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gMDsKfQogICAgICAgICAgICAgICAgLyogRmlnaHQgbm90IHRvIGJlIHRoZSBXaW5uZXIgLGJ1dCB0byBiZSB0aGUgbGFzdCBvbmUgdG8gbG9zZSAqLwo=