/*
DavitMarg
In a honky-tonk,
Down in Mexico
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <random>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair    
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0)
using namespace std;

const int N = 100005;

int n, k;
pair<int,int> lst[N][15];
LL dp[N][15],a[N],d;
vector<int> ans;
int main()
{
	fastIO;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + 1 + n);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= 9; j++)
			dp[i][j] = -mod * mod;
	dp[0][1] = 0;

	for (LL i = 1; i <= n; i++)
	{
		d = 1250;
		for (int j = 0; j < 10; j++)
		{
			dp[i][j] = dp[i - 1][j];
			lst[i][j] = MP(0, j);
		}
		for (int j = 0; j < 10; j++)
			if (dp[i - 1][j] + i + d >= dp[i][(j * a[i]) % 10])
			{
				dp[i][(j * a[i]) % 10] = dp[i - 1][j] + i + d;
				lst[i][(j * a[i]) % 10] = MP(1, j);
			}


	}

	if (dp[n][k] <= 0)
	{
		cout << -1 << endl;
		return 0;
	}

	while (n)
	{
		if (lst[n][k].first)
			ans.push_back(a[n]);
		k = lst[n][k].second;
		n--;
	}

	reverse(all(ans));
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++)
		cout << ans[i] << " ";
	cout << endl;


	return 0;
}

/*


*/