What is the smallest value of nnn such that a square of size n×nn \times nn×n can be divided into squares of sizes 40×4040 \times 4040×40 and 49×4949 \times 49, with both types of squares being present?