#K67947. Happy Number Checker
Happy Number Checker
Happy Number Checker
You are given a list of integers. For each integer, determine if it is a happy number. A number \( n \) is considered happy if, when you repeatedly replace it by the sum of the squares of its digits, the sequence eventually reaches 1. Formally, define \( s(n) = \sum_{d \in D(n)} d^2 \) where \( D(n) \) represents the digits of \( n \). If the repeated application of \( s(\cdot) \) eventually yields 1, then \( n \) is happy. Otherwise, it is unhappy.
For each integer in the input, output "ALEX IS HAPPY" if the number is happy, otherwise output "ALEX IS SAD".
inputFormat
The input begins with an integer \( T \) representing the number of integers to check. The next line contains \( T \) space-separated integers.
outputFormat
For each of the \( T \) integers, output a separate line containing either "ALEX IS HAPPY" if the number is happy or "ALEX IS SAD" if it is not.
## sample3
19 20 7
ALEX IS HAPPY
ALEX IS SAD
ALEX IS HAPPY
</p>