/**
   * Gets random value from given collection.
   *
   * @param c Input collection (no {@code null} and not emtpy).
   * @return Random value from the input collection.
   */
  @SuppressWarnings("UnusedDeclaration")
  private static <T> T rand(Collection<? extends T> c) {
    if (c == null) throw new IllegalArgumentException();

    int n = ThreadLocalRandom.current().nextInt(c.size());

    int i = 0;

    for (T t : c) {
      if (i++ == n) return t;
    }

    throw new ConcurrentModificationException();
  }