The Double-Castle Numbers™
Python 2, 83 81 79 72 bytes

-9 bytes thanks to @ovs!
-2 bytes thanks to @dingledooper!



m,n,a,B=input()
r=0
for s in n,m+n,m,m:r+=B**n;n-=~s
print~-B**n/~-B*a-r


Try it online!

Calculate aaaa...aaa in base B, then subtract 1 at the appropriate digits.