#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) REP(i, 0, n)
set<int> res;
void func(int k, int used_n, int n, int s, int goal, int v)
{
	if (k == n) {
		if (s == goal) res.insert(v);
		return;
	}
	rep(j, 10) if (!(used_n & (1<<j))) {
		func(k+1, used_n+(1<<j), n, s+(k+1)*j, goal, 10*v+j);
	}
}
int main()
{
	int n, s;
	while (cin >> n >> s) {
		res.clear();
		func(0, 0, n, 0, s, 0);
		for(typeof(res.begin())it=res.begin(); it!=res.end(); ++it)cout<<*it<<endl;
		cout << res.size() << endl;
	}
	return 0;
}