import java.util.*;

class RangeIterator implements Iterator<Integer> {
  
  private int start, end;

  /** An Iterator producing Integers with values in [start, end) in order:
    * start, start+1, start+2, ..., end-1.
    * Precondition: start <= end.
    * @param start  value of the first Integer to produce
    * @param end    one more than the value of the last Integer to produce */
  public RangeIterator(int start, int end) {
    if (start > end) throw new BadRangeException();
    this.start = start; this.end = end;
  } 
  public boolean hasNext() {
    return start < end;
  }
  public Integer next() {
    if (!hasNext()) throw new NoSuchElementException();
    return new Integer(start++);
  }
  public void remove() {
    throw new UnsupportedOperationException();
  }
  
}

class BadRangeException extends RuntimeException {}
