def pairwise(iterable):
    """ Return a generator which generate a pair wise list from an iterable.
    s -> (s[0],s[1]), (s[1],s[2]), ... (s[N-1],s[N])
    """
    prev = iterable[0]
    for x in iterable[1:]:
        yield prev, x
        prev = x
