#include #include #include #include #include #include #include #include #include #include #include #define Fail puts("NO"),exit(0); #define eps 1e-10 #define maxn 200010 #define maxm 100010 #define inf 1000000007 //#define mod 998244353 //#define inv 499122177 #define pi acos(-1) #define G 3 #define pi acos(-1) #define mp(x,y) make_pair(x,y) #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pairpii; typedef bitset bit; typedef long double ld; ll read() { ll x=0,f=1; char ch=getchar(); while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();} while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();} return x*f; } int T; int n,top; int a[maxn],res[maxn]; struct P{ int id,t,p; }p[maxn]; bool cmp(P a,P b) { return a.t