Bob is completing a true/false worksheet, consisting of a list of n problems where each answer is either “true” or “false”. The problems are numbered from 1 to n. They are too hard for Bob, so the TA, Alice, has given Bob m hints. For each hint i, Alice gives Bob an range of questions [li , ri ], and tells him either “all answers in the range are the same” ; or “not all of the answers in the range are the same.” Help Bob count how many different answer sequences satisfy the given hints. Since this number may be huge, print the answer modulo 109 + 7.
Bob is completing a true/false worksheet, consisting of a list of n problems where each answer is either “true” or “false”. The problems are numbered from 1 to n. They are too hard for Bob, so the TA, Alice, has given Bob m hints. For each hint i, Alice gives Bob an (inclusive) range of questions [li , ri ], and tells him either “all answers in the range are the same” (in other words, either all are “true”, or all are “false”); or “not all of the answers in the range are the same.” Help Bob count how many different answer sequences satisfy the given hints. Since this number may be huge, print the answer modulo 109 + 7.