CF678D Iterated Linear Function
Description
Consider a linear function $ f(x)=Ax+B $ . Let's define $ g^{(0)}(x)=x $ and $ g^{(n)}(x)=f(g^{(n-1)}(x)) $ for $ n>0 $ . For the given integer values $ A $ , $ B $ , $ n $ and $ x $ find the value of $ g^{(n)}(x) $ modulo $ 10^{9}+7 $ .
Input Format
The only line contains four integers $ A $ , $ B $ , $ n $ and $ x $ ( $ 1
Output Format
Print the only integer $ s $ — the value $ g^{(n)}(x) $ modulo $ 10^{9}+7 $ .