Problem: Diana loves playing with numbers. She's got n cards with positive integer numbers a_i written on them. She spends her free time multiplying the numbers on the cards. She picks a non-empty subset of the cards and multiplies all the numbers a_i written on them.

Diana is happy when the product of the numbers ends with her favorite digit d. Now she is curious what cards she should pick so that the product of the numbers on them is the largest possible and the last decimal digit of the product is d. Please, help her.

Input

The first line contains the integers n and d (1≤ n≤ 10^5, 0≤ d≤ 9). The second line contains n integers a_i (1≤ a_i≤ 1000). 

Output

On the first line, print the number of chosen cards k (1≤ k≤ n). On the next line, print the numbers written on the chosen cards in any order. 

If it is impossible to choose a subset of cards with the product that ends with the digit d, print the single line with -1.

Examples

Input


6 4
4 11 8 2 1 13


Output


5
1 2 4 11 13 


Input


3 1
2 4 6


Output


-1


Input


5 7
1 3 1 5 3


Output


-1


Input


6 3
8 9 4 17 11 5


Output


3
9 11 17 


Input


5 6
2 2 2 2 2


Output


4
2 2 2 2 

Note

In the first example, 1 × 2 × 4 × 11 × 13 = 1144, which is the largest product that ends with the digit 4. The same set of cards without the number 1 is also a valid answer, as well as a set of 8, 11, and 13 with or without 1 that also has the product of 1144.

In the second example, all the numbers on the cards are even and their product cannot end with an odd digit 1.

In the third example, the only possible products are 1, 3, 5, 9, 15, and 45, none of which end with the digit 7.

In the fourth example, 9 × 11 × 17 = 1683, which ends with the digit 3. 

In the fifth example, 2 × 2 × 2 × 2 = 16, which ends with the digit 6.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
const int MOD = 1000000007;

template <class T1, class T2>
istream& operator>>(istream& is, pair<T1,T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
    int N = v.size();
    for (int i=0; i<N; ++i)
        is >> v[i];
    return is;
}

// DEBUG printing

template <class T>
ostream& operator<<(ostream& os, vector<T> const& v);

template <class T1, class T2>
ostream& operator<<(ostream& os, pair<T1, T2> const& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, vector<T> const& v) {
    // os << "[";
    int n = v.size();
    if (n > 0)
        os << v[0];
    for (int i=1; i<n; ++i)
        os << " " << v[i];
    // os << "]";
    return os;
}

template <typename Iterator>
void print_seq(ostream& os, Iterator first, Iterator last) {
    os << "[";
    if (first != last) {
        os << *first;
        ++first;
    }
    for (; first != last; ++first)
        os << ", " << *first;
    os << "]";
}



typedef pair<int,vector<int>> Elem;

typedef tuple<ll,bool,int> Item;


void run(int tc) {
    int n, d;
    cin >> n >> d;
    bool odd = (d&1) == 1;
    bool not5 = d%5 != 0;
    vector<int> a;
    int prod = 1;
    for (int i=0; i<n; ++i) {
        int aa;
        cin >> aa;
        if ((odd and (aa&1) == 0) or (not5 and aa%5 == 0))
            continue;
        a.push_back(aa);
        prod = (prod*aa) % 10;
    }
    
    // cout << "Solving: n = " << n << "  d = " << d << "  a = " << a << "  prod = " << prod << endl;
    n = a.size();
    if (n == 0) {
        cout << "-1\n";
        return;
    }
    sort(a.begin(), a.end());
    // cout << "  a.sorted = " << a << endl;

    vector<map<int,Item>> dp(a.size());
    dp[0].emplace(a[0]%10, Item(1,true,-1));
    dp[0].emplace(-1, Item(a[0], false, -1));
    if (n > 1)
        dp[1].emplace(-1, Item(a[0]*a[1], false, -1));
    if (n > 2)
        dp[2].emplace(-1, Item(a[0]*a[1]*a[2], false, -1));

    function<void (int,int,ll,bool,int)> update = [&dp](int d, int idx, int val, bool inc, int prev) {
        auto iter = dp[idx].find(d);
        if (iter == dp[idx].end())
            dp[idx].emplace(d, Item(val, inc, prev));
        else {
            int val1 = std::get<0>(iter->second);
            if (val < val1)
                iter->second = Item(val, inc, prev);
        }
    };

    for (int i=1; i<n; ++i) {
        for (auto& elem : dp[i-1]) {
            int d1;
            if (elem.first == -1)
                d1 = a[i] % 10;
            else
                d1 = elem.first * a[i] % 10;
            
            int val = std::get<0>(elem.second);
            update(d1, i, val, true, elem.first);
            if (elem.first == -1)
                continue;
            if (val > 1000000)
                continue;
            val *= a[i];
            update(elem.first, i, val, false, elem.first);
        }
    }

    auto iter = dp[n-1].find(d);
    if (iter == dp[n-1].end()) {
        cout << "-1\n";
        return;
    }

    vector<int> result;
    int d1 = d;
    for (int i=n-1; i>=0; i--) {
        auto[val,inc,prev] = dp[i][d1];
        if (inc)
            result.push_back(a[i]);
        d1 = prev;
    }
    if (result.size() == 0) {
        cout << "-1\n";
        return;
    }
    cout << result.size() << "\n";
    cout << result << "\n";


    // int min_prod = 1000000001;
    // vector<int> excluded;
    // vector<vector<Elem>> dp(10, vector<Elem>(3, Elem(1000000001, vector<int>())));
    // dp[prod][0].first = 1;
    // if (prod == d and a.size() > 0)
    //     min_prod = 1;
    // // cout << "  min_prod = " << min_prod << endl;
    // // for (int ddd = 0; ddd < 10; ++ddd) {
    // //     cout << "  dp[" << ddd << "] = " << dp[ddd] << endl;
    // // }
    // for (int ai : a) {
    //     cout << "  - ai = " << ai << "  min_prod = " << min_prod << endl;
    //     for (int c = 2; c >= 0; --c) {
    //         for (int dd = 0; dd < 10; ++dd) {
    //             int p = dp[dd][c].first;
    //             int val = -1;
    //             if (p > 1000000000) {
    //                 if (c == 0)
    //                     val = ai;
    //                 else
    //                     continue;
    //             }
    //             else {
    //                 val = p * ai;
    //             }

    //             int d1 = val % 10;
    //             vector<int> new_arr = dp[dd][c].second;
    //             new_arr.push_back(ai);
    //             // cout << "      - dp[" << dd << "][" << c << "] = " << dp[dd][c] << "  val = " << val << "  d1 = " << d1 << endl; 
    //             if (d1*d%10 == prod and val < min_prod) {
    //                 min_prod = val;
    //                 excluded.swap(new_arr);
    //                 // cout << "         d*d1 % 10 = " << d*d1%10 << "  min_prod = min_prod" << endl;
    //             }
    //             else if (c < 2 and val < dp[d1][c+1].first) {
    //                 dp[d1][c+1].first = val; 
    //                 dp[d1][c+1].second.swap(new_arr);
    //                 // cout << "        dp[" << d1 << "][" << c+1 << "] updated to " << dp[d1][c+1] << endl;
    //             }
    //             else {

    //             }
    //         }
    //     }
    //     cout << "  - ai = " << ai << "  min_prod = " << min_prod << endl;
    //     for (int ddd = 0; ddd < 10; ++ddd) {
    //         cout << "    dp[" << ddd << "] = " << dp[ddd] << endl;
    //     }
    // }

    // if (min_prod == 1000000001) {
    //     cout << "-1\n";
    // }
    // else {
    //     int idx = 0;
    //     cout << a.size() - excluded.size() << endl;
    //     for (int i=0; i<a.size(); ++i) {
    //         if (idx < excluded.size() and a[i] == excluded[idx]) {
    //             idx++;
    //         }
    //         else
    //             cout << a[i] << " ";
    //     }
    //     cout << "\n";
    // }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    // cin >> T;
    for (int tc=1; tc<=T; tc++) {
        run(tc);
    }
}