class ABP {
constructor(v = 0, n = 100) {
this.A = new Int32Array(n);
this.B = new Int32Array(n);
this.S = new Int32Array(n);
this.v = v;
this.n = n;
this.top = 0;
}
defined(i) {
return (i < this.n && this.B[i] >= 0 && this.B[i] < this.top && this.S[this.B[i]] == i)
}
define (i) {
this.B[i] = this.top;
this.S[this.top++] = i;
}
set (i, x) {
this.A[i] = x;
if (!this.defined(i)) this.define(i);
}
get (i) {
if (this.defined(i)) return this.A[i];
return this.v
}
}