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.*;
import java.text.NumberFormat;
class main {
static class DeepBitSetWordIndex {
boolean _isTransient() { return true; }
  String regexp = "\\w+";
  Map singleTextIndices = new HashMap();
  ElementInstanceMatrix mainIndex = new ElementInstanceMatrix();
  void add(A a, String text) {
    singleTextIndices.put(a, new SingleTextWordIndex(regexp, text));
    mainIndex.add(a, mapToSet(__20 -> upper(__20),regexpExtractAll(regexp, text)));
  }
  
  void doneAdding() {
    mainIndex.doneAdding();
  }
  
  List> wordsAndOffsets(String text) {
    return map(regexpFindRanges(regexp, text),
      r -> pair(upper(substring(text, r)), r.start));
  }
  // assumes word boundaries left and right of query
  Collection preSearch(String query, Object... __) {
    boolean debug = boolPar("debug",__);
    List> l = wordsAndOffsets(query);
    Collection candidates = mainIndex.instancesContainingAllElements(pairsA(l));
    if (debug) {
      List lengths = map(candidates, a -> singleTextIndices.get(a).length);
      print(nCandidates(candidates) + ", total length: " + n2(intSum(lengths)) + ", lengths: " + lengths);
    }
    return filter(candidates, a -> nempty(singleTextIndices.get(a).indicesOfWordCombination(l)));
  }
  
  int numWords() { return mainIndex.numElements(); }
}
static HashSet mapToSet(Object f, Iterable l) {
  return mapToHashSet(f, l);
}
static  HashSet mapToSet(IF1 f, Iterable l) {
  return mapToSet((Object) f, l);
}
static  HashSet mapToSet(Iterable l, IF1 f) {
  return mapToSet((Object) f, l);
}
static String upper(String s) {
  return s == null ? null : s.toUpperCase();
}
static char upper(char c) {
  return Character.toUpperCase(c);
}
static List regexpExtractAll(String pat, String s) {
  if (s == null) return null;
  Matcher m = regexpMatcher(pat, s);
  List out = new ArrayList();
  while (m.find())
    out.add(m.group());
  return out;
}
static List map(Iterable l, Object f) { return map(f, l); }
static List map(Object f, Iterable l) {
  List x = emptyList(l);
  if (l != null) for (Object o : l)
    x.add(callF(f, o));
  return x;
}
  static  List map(Iterable l, F1 f) { return map(f, l); }
  static  List map(F1 f, Iterable l) {
    List x = emptyList(l);
    if (l != null) for (A o : l)
      x.add(callF(f, o));
    return x;
  }
static  List map(IF1 f, Iterable l) { return map(l, f); }
static  List map(Iterable l, IF1 f) {
  List x = emptyList(l);
  if (l != null) for (A o : l)
    x.add(f.get(o));
  return x;
}
  
static  List map(IF1 f, A[] l) { return map(l, f); }
static  List map(A[] l, IF1 f) {
  List x = emptyList(l);
  if (l != null) for (A o : l)
    x.add(f.get(o));
  return x;
}
  
static List map(Object f, Object[] l) { return map(f, asList(l)); }
static List map(Object[] l, Object f) { return map(f, l); }
static List map(Object f, Map map) {
  return map(map, f);
}
// map: func(key, value) -> list element
static List map(Map map, Object f) {
  List x = new ArrayList();
  if (map != null) for (Object _e : map.entrySet()) {
    Map.Entry e = (Map.Entry) _e;
    x.add(callF(f, e.getKey(), e.getValue()));
  }
  return x;
}
static  List map(Map map, IF2 f) {
  return map(map, (Object) f);
}
static List regexpFindRanges(String pat, String s) {
  Matcher m = regexpMatcher(pat, s);
  List l = new ArrayList();
  while (m.find())
    l.add(new IntRange(m.start(), m.end()));
  return l;
}
static  Pair pair(A a, B b) {
  return new Pair(a, b);
}
static  Pair pair(A a) {
  return new Pair(a, a);
}
static String substring(String s, int x) {
  return substring(s, x, strL(s));
}
static String substring(String s, int x, int y) {
  if (s == null) return null;
  if (x < 0) x = 0;
  if (x >= s.length()) return "";
  if (y < x) y = x;
  if (y > s.length()) y = s.length();
  return s.substring(x, y);
}
static String substring(String s, IntRange r) {
  return r == null ? null : substring(s, r.start, r.end);
}
// convenience method for quickly dropping a prefix
static String substring(String s, CharSequence l) {
  return substring(s, l(l));
}
static boolean boolPar(ThreadLocal tl) {
  return boolOptParam(tl);
}
// defaults to false
static boolean boolPar(Object[] __, String name) {
  return boolOptParam(__, name);
}
static boolean boolPar(String name, Object[] __) {
  return boolOptParam(__, name);
}
static boolean boolPar(String name, Map __) {
  return boolOptParam(name, __);
}
static boolean boolPar(String name, Object[] params, boolean defaultValue) {
  return optParam(params, name, defaultValue);
}
static  List pairsA(Collection> l) {
  return firstOfPairs(l);
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal