#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

struct Piece {
	int idx;
	int left;
	int right;
};

bool operator<( const Piece & a, const Piece & b ) {
	if ( a.left < b.left ) return true;
	if ( a.left > b.left ) return false;
	if ( a.right < b.right ) return true;
	if ( a.right > b.right ) return false;
	return false;
}

const Piece findPiece( const std::vector< Piece > & v, const Piece & p ) {
	return *std::find_if( v.begin(), v.end(), [ p ]( const Piece & i ) {
		return p.idx == i.idx;
	} );
}

int main() {
	std::vector< Piece > dominos = {
		{ 1, 1, 2 },
		{ 2, 2, 4 },
		{ 3, 2, 4 },
		{ 4, 6, 4 },
		{ 5, 2, 1 }
	};
	std::vector< Piece > dominosCopy{ dominos };
	bool all = false;
	std::vector< std::vector< Piece > > allPerm;
	do {
		allPerm.emplace_back( dominos.begin(), dominos.end() );
	} while ( std::next_permutation( dominos.begin(), dominos.end() ) );
	const int count = dominos.size();
	int goodPerm;
	for ( int perm = 0, size = allPerm.size(); perm < size && ! all; perm++ ) {
		bool ok = true;
		std::vector< Piece > & d = allPerm[ perm ];
		for ( int i = 1; i < count && ok; i++  ) {
			//cout << "( " << d[ i - 1 ].idx << " ) [ " << d[ i - 1 ].left << " " << d[ i - 1 ].right << " ]    ";
			if ( d[ i ].left == d[ i - 1 ].right || d[ i ].right == d[ i - 1 ].right ) {
				if ( d[ i ].right == d[ i - 1 ].right ) {
			  		std::swap( d[ i ].left, d[ i ].right );
				}
			}
			else {
				ok = false;
			}
		}
		//cout << "( " << d[ count - 1 ].idx << " ) [ " << d[ count - 1 ].left << " " << d[ count - 1 ].right << " ]" << endl;
		if ( ok ) {
			goodPerm = perm;
			all = true;
		}
	}
	if ( all ) {
		for ( const Piece & p : allPerm[ goodPerm ] ) {
			const Piece pCopy = findPiece( dominosCopy, p );
			cout << p.idx << " " << ( ( pCopy.left == p.left ) ? "+" : "-" );
			cout << "  [ " << pCopy.left << " " << pCopy.right << " ]" << endl;
		}
	}
	else {
		cout << "No solution" << endl;
	}
	return 0;
}