//In C++ 17 language #include using namespace std; typedef long long ll; vector determineDigits(ll n, ll d) { vector ans; // Always include 1 ans.push_back(1); // Include 3 if n >= 3 or d is divisible by 3 if (n >= 3 || d % 3 == 0) { ans.push_back(3); } // Include 5 if d is 5 if (d == 5) { ans.push_back(5); } // Include 7 if n >= 3 or (n == 2 and d == 7) if (n >= 3 || (n == 2 && d == 7)) { ans.push_back(7); } // Include 9 if special condition or n >= 6 if (n >= 6) { ans.push_back(9); } else { ll factorial = 1; int i = 2; while (i > t; while (t--) { ll n, d; cin >> n >> d; vector ans = determineDigits(n, d); for (int digit : ans) { cout