# Path: misc/numerical.py
# INF = float('inf')


from random import shuffle, choice
from itertools import cycle, islice, permutations, chain, product, count
from collections import Iterable
from functools import reduce
from .numerical import INF
import operator
import time
def safe_minmax(iterable_of_iterables):
  return safe_min([safe_max(iterables) for iterables in iterable_of_iterables])

def safe_index(sequence, value, default=-1):
  if value not in sequence:
    return default
  return sequence.index(value)

def pairs(lst):
  return zip(lst[:-1], lst[1:])

def randomize(sequence):
  shuffle(sequence)
  return sequence

def random_sequence(sequence):
  indices = range(len(sequence))
  shuffle(indices)
  for i in indices:
    yield sequence[i]

def reverse(iterable):
  return reversed(list(iterable))

def flatten(iterable_of_iterables):
  return (item for iterables in iterable_of_iterables for item in iterables)

def squash(nested_iterables):
  result = []
  for item in nested_iterables:

# Path: misc/numerical.py
# INF = float('inf')


# Path: misc/functions.py
from random import shuffle, choice
from itertools import cycle, islice, permutations, chain, product, count
from collections import Iterable
from functools import reduce
from .numerical import INF
import operator
import time

def safe_minmax(iterable_of_iterables):
  return safe_min([safe_max(iterables) for iterables in iterable_of_iterables])

def safe_index(sequence, value, default=-1):
  if value not in sequence:
    return default
  return sequence.index(value)

def pairs(lst):
  return zip(lst[:-1], lst[1:])

def randomize(sequence):
  shuffle(sequence)
  return sequence

def random_sequence(sequence):
  indices = range(len(sequence))
  shuffle(indices)
  for i in indices:
    yield sequence[i]

def reverse(iterable):
  return reversed(list(iterable))

def flatten(iterable_of_iterables):
  return (item for iterables in iterable_of_iterables for item in iterables)

def squash(nested_iterables):
  result = []
  for item in nested_iterables:

    if isinstance(item, Iterable):