Introduction
A double-castle number™ is a positive integer number that has a pattern of $$\underbrace{a\cdots a}_{m\text{ }a\text{s}}b\underbrace{a\cdots a}_{m\text{ }a\text{s}}b\underbrace{a\cdots a}_{m\text{ }a\text{s}}\underbrace{a\cdots a}_{n\text{ }a\text{s}}b\underbrace{a\cdots a}_{n\text{ }a\text{s}}b\underbrace{a\cdots a}_{n\text{ }a\text{s}}$$ Where \$m>0\$, \$n>0\$ and \$a-b=1\$ are all non-negative integers, when represented in an integer base \$B\$ where \$B\ge2\$. It is so named because a bar chart representing the base-\$B\$ digits of such a number resembles two castles of the same height place- side by side.
For example, \$7029\$* is a double-castle number because when represented in base 2 it becomes \$1101101110101_2\$, which can be split into \$11011011\$ and \$10101\$.
This is the case when \$m=2\$, \$n=1\$, \$a=1\$, \$b=0\$ and \$B=2\$.
\$305421994212\$ is also a double-castle number because when represented in base 8 it becomes \$4343444344344_8\$, which can be split into \$43434\$ and \$44344344\$.
This is the case when \$m=1\$, \$n=2\$, \$a=4\$, \$b=3\$ and \$B=8\$.
For \$a>=10\$, \$a\$ should be treated as a single base-\$B\$ "digit" with the value of \$a\$ in base-10. \$206247763570426655730674346\$ is a double-castle number in base-16, whose representation in base-16 is \$\text{AA9AA9AAAAAA9AAAA9AAAA}_{16}\$. Here, \$a=10\$ but is treated as a single digit \$(10)_{16}=\text{A}_{16}\$.
This is the case when \$m=2\$, \$n=4\$, \$a=10\$, \$b=9\$ and \$B=16\$.
Challenge
Write a program or function that, given integers \$m>0\$, \$n>0\$, \$1\le a<B\$ and \$B\ge2\$, calculate the corresponding double-castle number™ and output it in base-10.
Test Cases
The input below are in base-10, but in the case say when \$a=11\$ and \$B=12\$ the input should be understood as \$B_{12}\$.
m, n, a, B => Output
1, 1, 1, 2 => 693
2, 1, 1, 2 => 7029
1, 2, 3, 4 => 62651375
1, 2, 4, 8 => 305421994212
1, 4, 7, 10 => 7676777776777767777
2, 4, 8, 16 => 164983095594247313234036872
2, 4, 10, 16 => 206247763570426655730674346
Winning Condition
This is a code-golf challenge, the shortest submission in each language wins. No standard loopholes allowed.
*7029 comes from my ID minus it written reversed.
2, 4, 10, 16 => 206247763570426655730674346
). Also, maybe some test cases wheren
andm
are larger than 10. And change the term 'digits' to 'numbers' in the sentence "It is so named because a bar chart representing the digits of such a number resembles two castles of the same height placed side by side." please, since it's incorrect and actually made me thing we only had to work with digits. \$\endgroup\$