from typing import List
from typing import Any
from typing import Iterator
from typing import Tuple
import itertools


def pairwise(s: List[Any]) -> Iterator[Tuple[Any, Any]]:
    """
    Iterates over neighbors in a list.

    s -> (s0,s1), (s1,s2), (s2, s3), ...

    From https://stackoverflow.com/a/5434936
    """

    a, b = itertools.tee(s)
    next(b, None)
    return zip(a, b)