Let be the th prime number (starting at 0): Define as the remainder of modulo . For instance, , because
Given two integer numbers and , find the largest such that .
Input consists of several cases, each one with two integer numbers and , where and .
For every case, print the largest such that .
Input
1 1 2 2 1 2 3 3 1 10 1 100 1 1000 600000 600002
Output
6 2 6 42 522 107118 15822162 10752590320954