Loop to count the number of paths from a point to origin in bottom - up manner
for i in range ( 1 , q + 1 ) : NEW_LINE INDENT for j in range ( 1 , p + 1 ) : NEW_LINE INDENT dp [ j ] += dp [ j - 1 ] NEW_LINE DEDENT DEDENT return dp [ p ] NEW_LINE