Given two numbers N and M, find the number of arrays of length N which satisfy the following conditions -