Python Bottom Up TLE (TILING PROBLEM 2)

I am trying to submit a bottom-up solution using python but 2 test cases are showing tle error.
CODE:

def tileBU(n, m): 
    dp =[0]*(n+1) 
    for i in range(1, n + 1): 
        if i < m:  
            dp[i] = 1
        elif i == m: 
            dp[i] = 2
        else:
            dp[i] = dp[i-1] + dp[i-m]
    return dp[n] 
MOD = (10**9) + 7
T = int(input())
for i in range(T):
    n,m = map(int,input().split())
    print(tileBU(n,m)%MOD)