I was trying to solve this problem uva 13136 Recurrences .
But, I couldn't manage to understand the output.
For example in test case 1, n = 1,A0 = 1,B0 = 2,C0 = 3. So, According the relations given, I should get, S0 = 0 A1 = 4-6-9=11 B1 = 5-8-12 = -15 C1 = 2-1 = 1 S1 = 0+(-11)*(-15)+1 = 166 so,ans should be 166%10 = 6. But the output is given 5.