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 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 javax.imageio.*; import java.math.*; class main { static int[] intersectIntArrayAndBitSet(int[] array, BitSet bs) { if (array == null || bs == null) return null; int n = array.length; IntBuffer out = new IntBuffer(n); for (int i = 0; i < n; i++) { int x = array[i]; if (bs.get(x)) out.add(x); } return out.toArray(); } static class IntBuffer { int[] data; int size; IntBuffer() {} IntBuffer(int size) { if (size != 0) data = new int[size]; } void add(int i) { if (size >= lIntArray(data)) data = resizeIntArray(data, Math.max(1, lIntArray(data)*2)); data[size++] = i; } int[] toArray() { return size == 0 ? null : resizeIntArray(data, size); } void reset() { size = 0; } } static int lIntArray(int[] a) { return a == null ? 0 : a.length; } static int[] resizeIntArray(int[] a, int n) { if (n == lIntArray(a)) return a; int[] b = new int[n]; arraycopy(a, 0, b, 0, Math.min(lIntArray(a), n)); return b; } static void arraycopy(Object[] a, Object[] b) { if (a != null && b != null) arraycopy(a, 0, b, 0, Math.min(a.length, b.length)); } static void arraycopy(Object src, int srcPos, Object dest, int destPos, int n) { if (n != 0) System.arraycopy(src, srcPos, dest, destPos, n); } }