func_code_string: #include <bits/stdc++.h>   #define pb push_back   #define mp make_pair   #define sz(a) ((int)a.size())   #define re return   #define all(a) a.begin(),a.end()   #define int long long   #define ld long double   #define rept(i,a,b) for(int i=(a);i<(b);i++)   #define rep(i,a) rept(i,0,a)   using namespace std;   void fail(string s){ cout<<s;exit(0); }   void fail(int s){ cout<<s;exit(0); }   void chmax(ld &a,ld b,pair<int,int> &c,pair<int,int> d){ if (b>a) a=b,c=d; }   int n,d;   int a[100005];   ld dp[100005][10];   ld lg[100005];   pair<int,int>l[100005][10];   signed main(){    cin>>n>>d;    rept(i,1,n+1){     cin>>a[i];     lg[i]=log2(a[i]);    }    rep(i,n+1) rep(j,10) dp[i][j]=-1.0;    dp[0][1]=0.0;    rep(i,n){     rep(j,10){      if (dp[i][j]>=0.0){       chmax(dp[i+1][j],dp[i][j],l[i+1][j],mp(0,j));       chmax(dp[i+1][j*a[i+1]%10],dp[i][j]+lg[i+1],l[i+1][j*a[i+1]%10],mp(1,j));      }     }    }    int pos=-1;    ld ans=0.0;     rept(i,1,n+1){     if (dp[i][d]>=ans){      ans=dp[i][d];      pos=i;     }    }    vector<int>v;    int x=l[pos][d].first,y=l[pos][d].second;    for (int i=pos-1;i>=0;i--){     if (x)      v.pb(i+1);     x=l[i][y].first,y=l[i][y].second;    }    if (!sz(v))     fail(-1);    cout<<sz(v)<<  n ;    rep(i,sz(v))     cout<<a[v[i]]<<   ;    return 0;   }   