#include using namespace std; #define ll long long int #define ull unsigned long long int #define LL long long #define ULL unsigned long long #define sc(a) scanf("%d",&a) #define sc2(a,b) scanf("%d%d",&a,&b) #define SC scanf #define PC printf #define I(a) scanf("%d",&a) #define I2(a,b) scanf("%d%d",&a,&b) #define I3(a,b,c) scanf("%d%d%d",&a,&b,&c) #define L(a) scanf("%lld",&a) #define L2(a,b) scanf("%lld%lld",&a,&b) #define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define SS(s) scanf("%s",s) //#define I(X ) scanf("%d",&X) #define II(X, Y) scanf("%d%d",&X,&Y) #define III(X, Y, Z) scanf("%d%d%d",&X,&Y,&Z) #define DI(X) int X; I(X); #define DII(X, Y) int X, Y; II(X,Y) #define DIII(X, Y, Z) int X, Y, Z; III(X,Y,Z); #define IL(X ) scanf("%lld",&X) #define IIL(X, Y) scanf("%lld%lld",&X,&Y) #define IIIL(X, Y, Z) scanf("%lld%lld%lld",&X,&Y,&Z) #define DIL(X) LL X; IL(X); #define DIIL(X, Y) LL X, Y; IIL(X,Y) #define DIIIL(X, Y, Z) LL X, Y, Z; IIIL(X,Y,Z); #define f(i,n) for(i=0;i=b; i--) #define rep(i,a,b) for(int i=a;i<=b;i++) #define rev(i,a,b) for(int i=a;i>=b;i--) #define repv(i,a) for(int i=0;i<(int)a.size();i++) #define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--) #define mk make_pair #define MP make_pair #define pb push_back #define PB push_back #define aov(a) a.begin(),a.end() #define all(a) a.begin(),a.end() #define endl '\n' #define Endl '\n' #define nl puts("") #define NL printf("\n") #define PI (2.0*acos(0.0)) //#define PI acos(-1.0) #define dbg(x) cerr<<#x<<" : "< inline T bigmod(T p,T e,T M) { ll ret = 1; for(; e > 0; e >>= 1) { if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template inline T bpow(T p,T e) { ll ret = 1; for(; e > 0; e >>= 1) { if(e & 1) ret = (ret * p); p = (p * p); } return (T)ret; } template inline T modinverse(T a,T M) { return bigmod(a,M-2,M); } /// M is prime template inline T gcd(T a,T b) { if(b==0)return a; return gcd(b,a%b); } ///int mnth[]={-1,31,28,31,30,31,30,31,31,30,31,30,31}; //Not Leap Year ///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction ///int dx[]={-1,+1,0,1,0,-1}; // Hexagonal Direction ** ///int dy[]={-1,+1,1,0,-1,0}; // *#* /// ** ///const double eps=1e-9; /// 0123456789ABCDEF #define Base1 10000019ULL #define Base2 10000079ULL #define Base3 10000103ULL #define MOD1 1000000007ULL #define MOD2 1000000009ULL #define MOD3 1000000021ULL #define CLR(a) memset(a,0,sizeof(a)) /// 0123456789ABCDEF #define M 100005 #define MOD 1000000007LL #define MX 4000005 #define F(i,a,b) for(int i=a;i=k) { la=l; } } if(la!=-1) { for(int lp=j;lp<=la;lp++) { tree[lp]=max(tree[lp],la-j+1); } } int ans=tree[j]; printf("%d\n",ans>0?ans:-1); } return 0; }