#include using namespace std; using ll = long long; using ld = long double; #define print(x) cerr << #x << " = " << x << endl unordered_map seen; template ostream& operator<<(ostream &out, vector &cont) { out << "["; for (const auto &x : cont) out << x << ", "; out << "]"; return out; } bool isPrime(int n){ if(n < 2) return false; if (n % 2 == 0) return false; for(int i=3; i*i<=n; i += 2){ if(n%i == 0) return false; } return true; } int solve(int n){ if(n == 0 || !isPrime(n)) return 0; if (seen.find(n) != seen.end()){ return seen[n]; } int n2 = n, i = 1; vector a; while(n2 != 0){ a.push_back(i*(n2%10)); i *= 10; n2 /= 10; } int maxAns = 0; for(int i=0; i> n; cout << solve(n) << '\n'; }