def get_coincidence(period1:int, start1:int, period2:int, start2:int)->int:
    """Get the first coincidence of two sequences with given period and starts.
    period1 is assumed to be larger if of extremely different sizes."""
    val = start1
    while (val - start2) % period2:
        val += period1
    
    return val