import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import java.util.function.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;
class main {
static CloseableIterableIterator closeableIterableIterator(Iterator it) {
if (it instanceof CloseableIterableIterator) return ((CloseableIterableIterator) it);
return it == null ? null : new CloseableIterableIterator() {
public boolean hasNext() { return it.hasNext(); }
public A next() { return it.next(); }
public void remove() { it.remove(); }
public void close() { try { closeOpt(it); } catch (Exception __e) { throw rethrow(__e); } }
};
}
static CloseableIterableIterator closeableIterableIterator(Collection it) {
return closeableIterableIterator(iterator(it));
}
static void closeOpt(Object c) {
if (c instanceof AutoCloseable) _close((AutoCloseable) c);
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static RuntimeException rethrow(String msg, Throwable t) {
throw new RuntimeException(msg, t);
}
static Iterator iterator(Iterable c) {
return c == null ? emptyIterator() : c.iterator();
}
static void _close(AutoCloseable c) {
if (c != null) try {
c.close();
} catch (Throwable e) {
// Some classes stupidly throw an exception on double-closing
if (c instanceof javax.imageio.stream.ImageOutputStream)
return;
else throw rethrow(e);
}
}
static void _handleError(Error e) {
//call(javax(), '_handleError, e);
}
static Iterator emptyIterator() {
return Collections.emptyIterator();
}
static abstract class CloseableIterableIterator extends IterableIterator implements AutoCloseable {
public void close() throws Exception {}
}
// you still need to implement hasNext() and next()
static abstract class IterableIterator implements Iterator, Iterable {
public Iterator iterator() {
return this;
}
public void remove() {
unsupportedOperation();
}
}
static UnsupportedOperationException unsupportedOperation() {
throw new UnsupportedOperationException();
}
}