#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
string a = "send";
string b = "more";
string c = "money";
bool satisfyCondition(map <char, int> assigned){
if(assigned[a[0]] == 0 || assigned[b[0]] == 0 || assigned[c[0]] == 0) return 0;
int stringA = 0;
int stringB = 0;
int stringC = 0;
for(int i = 0; i< a.length(); i++){
stringA = stringA*10 + assigned[a[i]];
}
for(int i = 0; i< b.length(); i++){
stringB = stringB*10 + assigned[b[i]];
}
for(int i = 0; i< c.length(); i++){
stringC = stringC*10 + assigned[c[i]];
}
if((stringA + stringB) == stringC) return 1;
else return 0;
}
bool CalculatePuzzle(map<char, int> &assigned, string lettersToAssign,string fullString){
if(lettersToAssign.empty()){
// for(int i = 0 ; i< fullString.size();i++ )
// cout << fullString[i] << " " << assigned[fullString[i]] << endl;
// cout << endl << endl;
return satisfyCondition(assigned);
}
for(int i = 9; i >=0; i--){
char toAssign = lettersToAssign[0];
// cout << toAssign << endl;
bool present = 0;
for(map <char, int>::iterator it = assigned.begin(); it != assigned.end(); it++)
{
if(it->second == i){
present = 1;
}
}
if(present == 1) continue;
assigned[toAssign] = i;
bool b = CalculatePuzzle(assigned, lettersToAssign.substr(1),fullString);
if(b == 1)
return 1;
else{
assigned[toAssign] = -1;
}
}
return 0;
}
int main(){
map <char, int> assigned;
string letters;
int frequency[26] = {0};
for(int i = 0; i< a.length(); i++){
if(frequency[a[i]-'a']++ == 0){
//assigned[a[i]]++;
letters+= a[i];
}
}
for(int i = 0; i< b.length(); i++){
if(frequency[b[i]-'a']++ == 0){
//assigned[b[i]]++;
letters+= b[i];
}
}
for(int i = 0; i< c.length(); i++){
if(frequency[c[i]-'a']++ == 0){
//assigned[c[i]]++;
letters+= c[i];
}
}
for(int i = 0; i < letters.size(); i++){
assigned[letters[i]] = -1;
}
// cout << letters << endl;
bool b = CalculatePuzzle(assigned,letters,letters);
if (b == 0) {
cout << "No solution" << endl;
}
else{
for(map <char, int>::iterator it = assigned.begin(); it != assigned.end(); it++){
cout << it->first << " " << it->second << endl;
}
}
cout << endl;
}