Let A1A2A3A4A5A6A7A8 be a regular octagon. Let M1, M3, M5, and M7 be the midpoints of sides A1A2, A3A4, A5A6, and A7A8, respectively. For i=1,3,5,7, ray Ri is constructed from Mi towards the interior of the octagon such that R1⊥R3, R3⊥R5, R5⊥R7, and R7⊥R1. Pairs of rays R1 and R3, R3 and R5, R5 and R7, and R7 and R1 meet at B1, B3, B5, B7 respectively. If B1B3=A1A2, then cos2∠A3M3B1 can be written in the form m−n, where m and n are positive integers. Find m+n.