In the Fibonacci sequence, F0=0, F1=1, and Fn=Fn−1+Fn−2 for n≥2. For example, the first ten terms of the sequence are:
0,1,1,2,3,5,8,13,21,34,…
An equivalent formulation uses matrix exponentiation:
[Fn+1FnFnFn−1]=[1110]n
Given an integer n, compute the last four digits of Fn.
The input contains multiple test cases. Each test case is a single line holding an integer n with 0≤n≤1,000,000,000. The input ends with a single line containing −1, which is not part of the data.
For each test case, print the last four digits of Fn on its own line. If those four digits are all zero, print 0; otherwise omit any leading zeros. In other words, print Fnmod10000.