class Lock {
  public Thread owner;
  public int level;

  private final LinkedList<Thread> q;

  Lock() {
    level = 0;
    owner = null;
    q = new LinkedList<Thread>();
  }

  public Thread nextThread() {
    return q.getFirst();
  }

  public Thread deQ(Thread t) throws IllegalMonitorStateException {<FILL_FUNCTION_BODY>}

  public void enQ(Thread t) {
    q.add(t);
  }
}

    if (t != q.getFirst()) {
      throw new IllegalMonitorStateException();
    }

    return q.removeFirst();
  
<no_super_class>