/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Stairs s = new Stairs(5, 10);
for (int i = 0; i <= 20; ++i) {
}
}
}
class Stairs {
private int min;
private int max;
private int diff;
private int value;
public Stairs(int min, int max) {
this.min = min;
this.max = max;
this.diff = max - min;
this.value = diff - 1;
}
public int next() {
value = (value + 1) % (2 * diff);
return min
+ Math.
abs(value
- diff
); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0YWlycyBzID0gbmV3IFN0YWlycyg1LCAxMCk7CgkJCgkJZm9yIChpbnQgaSA9IDA7IGkgPD0gMjA7ICsraSkgewoJCQlTeXN0ZW0ub3V0LnByaW50bG4ocy5uZXh0KCkpOwoJCX0KCX0KfQoKY2xhc3MgU3RhaXJzIHsKCXByaXZhdGUgaW50IG1pbjsKCXByaXZhdGUgaW50IG1heDsKCXByaXZhdGUgaW50IGRpZmY7Cglwcml2YXRlIGludCB2YWx1ZTsKCglwdWJsaWMgU3RhaXJzKGludCBtaW4sIGludCBtYXgpIHsKCQl0aGlzLm1pbiA9IG1pbjsKCQl0aGlzLm1heCA9IG1heDsKCQl0aGlzLmRpZmYgPSBtYXggLSBtaW47CgkJdGhpcy52YWx1ZSA9IGRpZmYgLSAxOwoJfQoJCglwdWJsaWMgaW50IG5leHQoKSB7CgkJdmFsdWUgPSAodmFsdWUgKyAxKSAlICgyICogZGlmZik7CgkJcmV0dXJuIG1pbiArIE1hdGguYWJzKHZhbHVlIC0gZGlmZik7Cgl9Cn0K