\[\large 54841 = 317 \times 173.\]
54841, whose prime factor decomposition is given above, can be written as the sum of two perfect squares in two different ways:
\[54841 = a^2 + b^2 = c^2 + d^2,\]
where \(a,b,c\) and \(d\) are distinct positive integers. Find the sum \(a+b+c+d\).
Hint: \(317 = 196 + 121\), and \(173 = 169 + 4\).