Correct way to add numbers to get lots of 8's Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display them in a 7-segment display.  For reference, the digits are represented in the following way:

 _        _   _         _    _   _    _    _
| |   |   _|  _|  |_|  |_   |_    |  |_|  |_|
|_|   |  |_   _|    |   _|  |_|   |  |_|   _| 


Note that the 1 uses the two segments on the right, not the left.  There are two special characters that can be produced this way which are not numbers.  See the addition table below:

  | 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 8 8 8 8 8 0 8 8
1 | 0 1 a 3 4 9 8 7 8 9
2 | 8 a 2 a 8 8 8 a 8 8
3 | 8 3 a 3 9 9 8 3 8 9
4 | 8 4 8 9 4 9 8 Q 8 9
5 | 8 9 8 9 9 5 6 9 8 9
6 | 8 8 8 8 8 6 6 8 8 8
7 | 0 7 a 3 Q 9 8 7 8 9
8 | 8 8 8 8 8 8 8 8 8 8
9 | 8 9 8 9 9 9 8 9 8 9


Useful observations:


Any digit plus itself equals itself
8 plus any digit equals 8
2 plus 1, 3, or 7 equals the letter 'a' (must be lower-case)
4 plus 7 equals either 'q' or 'Q', your choice
Numbers should be right-aligned, so the digits should be added from right to left.  If one number has more digits than the other, the extra digits at the beginning should be unchanged.  There are no leading 0's, unless the number is exactly 0.
All numbers will be 0 or greater.  You don't need to handle a '-' sign.  (Mainly because there's no good fit for the sum of a '-' and a '1' or '7'.)


Your program should accept 2 integers in any format you choose, and output a string containing their "sum" when calculated in this manner.  This is code-golf, so your program should be as small as possible.

Examples:


Input: 12345, 123.  Output: 12389
Input: 88888, 42.  Output: 88888
Input: 0, 23.  Output: 28
Input: 120, 240.  Output: a80
Input: 270, 42.  Output: 2Q8 (or 2q8)
Input: 1234567890, 1234567890.  Output: 1234567890
Bash + Common Linux utilities, 80

s=~0my3[_p^?{}s
h()(tr 0-9 $s&lt;&lt;&lt;$1|xxd -p)
dc -e$[0x`h $1`|0x`h $2`]P|tr $s 0-9aQ

Note the ^? in the source should be replaced with an ASCII 0x7f character.
The string s is each 7 segment digit 0-9, a, Q encoded with each segment corresponding to a bit of an ASCII char.
The h() function transliterates the input number from decimal to the encoding specified by s, then outputs the result as a raw hex string.
The two resulting raw hex strings are ORed together using regular bash arithmetic, then output by dc's P command as a bytestream.  This bytestream is then transliterated back to decimal + a + Q and output.
Note also that when using the &lt;&lt;&lt; bash herestring construct in function h() a newline is implicitly appended to the redirected string.  This doesn't matter - it is simply translated to 0x0a at the end of each hex string; when the two hex numbers are ORed together, the result is still 0x0a in the last char which doesn't get transliterated and thus simply translates back to a newline which is output after the result.
Test output:
$ for testcase in \
&gt; &quot;12345 123&quot; \
&gt; &quot;88888 42&quot; \
&gt; &quot;0 23&quot; \
&gt; &quot;1234 56789&quot; \
&gt; &quot;4 7&quot;; do 
&gt; ./7segadd.sh $testcase
&gt; done
12389
88888
28
58a89
Q
$