Take an integer N and replace it by the sum of the squares of its digits. A number is happy when repeating this step eventually produces 1. Starting from 82, for example:
8*8 + 2*2 = 64 + 4 = 68
6*6 + 8*8 = 36 + 64 = 100
1*1 + 0*0 + 0*0 = 1 + 0 + 0 = 1
The process reached 1, so 82 is happy.
The same number can be happy in one base and not happy in another. The base 10 number 82 is written 10001 in base 3, and in base 3 the process never reaches 1.
Happiness in base b is defined this way. Write the number in base b and add up the squares of its digits to get a new number. Repeat. If 1 ever comes out, the number is happy in base b.
Given a list of bases, find the smallest integer greater than 1 that is happy in every one of those bases.