#B3828. Excellent Perfect Square Product

    ID: 11485 Type: Default 1000ms 256MiB

Excellent Perfect Square Product

Excellent Perfect Square Product

An integer \(x\) is defined as an excellent positive integer if it meets the following criteria:

  • \(x\) is a perfect square, i.e. there exists some integer \(k\) such that \(x=k^2\).
  • The sum of the digits of \(x\) is a prime number.

For example, \(25\) is an excellent positive integer because \(25=5\times5\) and the digit sum \(2+5=7\) is prime.

You are given two positive integers \(L\) and \(R\). Your task is to compute the product of all excellent positive integers between \(L\) and \(R\) (inclusive) modulo \(998244353\). If there are no excellent positive integers in the given interval, output \(0\).

inputFormat

The input consists of a single line containing two space-separated integers \(L\) and \(R\) \( (1 \leq L \leq R) \).

outputFormat

Output a single integer which is the product of all excellent positive integers in the interval \([L, R]\), taken modulo \(998244353\). If no such number exists, output \(0\).

sample

1 100
19600