#include using namespace std; typedef long long ll; int n; int rec[50500][4]; struct node{ int t; int id; int tag; }que[105000]; bool operator <(const node& a, const node& b){ if(a.t!=b.t)return a.t