def safeMod(x, m):
    """
    The safe module of integers, work for both positive and negative integers.

    Parameters
    ----------
    x : int
        An integer to take module.
    m : int
        A positive integer as the module.

    Returns
    -------
    int
        A positve integer in [0, m) as the remainder of x.
    """
    return ((x % m) + m) % m