#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } template struct BIT{ Int n; vector bit; // 1-indexed BIT(Int n_):n(n_+1),bit(n+1,0){} T sum(Int i){ T s(0); for(Int x=i;x>0;x-=(x&-x)) s+=bit[x]; return s; } void add(Int i,T a){ if(i==0) return; for(Int x=i;x<=n;x+=(x&-x)) bit[x]+=a; } // [l, r) T query(Int l,Int r){ return sum(r-1)-sum(l-1); } Int lower_bound(Int w){ if(w<=0) return 0; Int x=0,r=1; while(r0;k>>=1){ if(x+k<=n&&bit[x+k] vs){ Int n=vs.size(); BIT bit(n+10); Int res=0; for(Int i=0;i>n; auto as=read(n); auto bs=read(n); if(as[0]!=bs[0]) drop(-1); vector xs(n-1),ys(n-1); for(Int i=0;i+1; map app; map idx; for(Int i=0;i+1 ps(n-1); for(Int i=0;i+1