Problem

Source: China Team Selection Test 2016 Test 3 Day 2 Q4

Tags: number theory



Let $a,b,b',c,m,q$ be positive integers, where $m>1,q>1,|b-b'|\ge a$. It is given that there exist a positive integer $M$ such that $$S_q(an+b)\equiv S_q(an+b')+c\pmod{m}$$ holds for all integers $n\ge M$. Prove that the above equation is true for all positive integers $n$. (Here $S_q(x)$ is the sum of digits of $x$ taken in base $q$).