#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct Card {
	int type;
	int num;
	Card(const int _type, const int _num) :type(_type), num(_num) {
		assert(type >= 0 && type <= 3);
		assert(num >= 1 && num <= 13);
	}
	Card() :type(-1), num(-1) {

	}
	bool operator <(const Card& c) {
		return num == c.num ? type < c.type : num < c.num;
	}
};
long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}
struct Poker {
	vector<Card>cards;
	long long getnumpower(
		const vector<pair<int, int>>&numcount) {
		
		long long int apower = 0;
		for (int i = 0; i < numcount.size(); ++i) {
			apower += numcount[i].second*powint(100,numcount.size() - 1 - i);
		}
		return apower;
	}
	long long getpower(){
		sort(cards.begin(), cards.end());
		bool isflush = false;
		{
			const int type0 = cards[0].type;
			isflush =
				all_of(cards.begin(), cards.end(), [=](const Card&c) {return c.type == type0; });
		}
		bool isstraight = false;
		{
			const int amin = cards[0].num;
			int place = -1;
			isstraight =
				all_of(cards.begin(), cards.end(), [=,&place](const Card&c) {place++; return c.num == amin+place; });
			bool royalok = true;
			for (int i = 0; i < 5; ++i) {
				if (i!= 0) {
					if (cards[i].num != 9 + i) {
						royalok = false;
						break;
					}
				}
				else {
					if (cards[i].num != 1) {
						royalok = false;
						break;
					}
				}
			}
			if (royalok) {
				isstraight = true;
			}
			if (isstraight) {
				int a=0;
				a++;
			}
		}
		vector<pair<int,int>>numcount;
		{
			map<int, int>powermp =
			{
				{ 1,14 },
				{ 2,2 },
				{ 3,3 },
				{ 4,4 },
				{ 5,5 },
				{ 6,6 },
				{ 7,7 },
				{ 8,8 },
				{ 9,9 },
				{ 10,10 },
				{ 11,11 },
				{ 12,12 },
				{ 13,13 },
			};
			vector<int>allnumcount(13);
			for (int i = 0; i < cards.size(); ++i) {
				allnumcount[cards[i].num - 1]++;
			}
			for (int i = 0; i < 13; ++i) {
				if (allnumcount[i]) {
					numcount.emplace_back(allnumcount[i],powermp[i+1]);
				}
			}
			sort(numcount.begin(), numcount.end(), greater<pair<int,int>>());
		}

		const long long int rolevalue = 1e16;
		
		
		//straightflush
		if (isstraight&&isflush) {
			assert(numcount.size() == 5);
			if(cards[0].num==1&&cards[1].num==10)return 10 * rolevalue + 100;
			return 10 * rolevalue +cards[0].num ;
		}

		//fourcard
		if (numcount[0].first == 4) {
			assert(numcount.size() == 2);
			return 9 * rolevalue + getnumpower(numcount);
		}

		//fullhouse
		if (numcount[0].first == 3 && numcount[1].first == 2) {
			assert(numcount.size() == 2);
			return 8 * rolevalue + getnumpower(numcount);
		}
		//flush
		if (isflush) {
			assert(numcount.size() == 5);
			return 7 * rolevalue + getnumpower(numcount);
		}
		//straight
		if (isstraight) {
			assert(numcount.size() == 5);
			if (cards[0].num == 1 && cards[1].num == 10)return 6 * rolevalue + 100;
			return 6 * rolevalue + cards[0].num;
		}
		//three of a kind
		if (numcount[0].first == 3) {
			assert(numcount.size() == 3);
			return 5 * rolevalue + getnumpower(numcount);
		}
		// two pair
		if (numcount[0].first == 2 && numcount[1].first == 2) {
			assert(numcount.size() == 3);
			return 4 * rolevalue + getnumpower(numcount);
		}
		//one pair
		if (numcount[0].first == 2) {
			assert(numcount.size() == 4);
			return 3 * rolevalue + getnumpower(numcount);
		}
		// no pair
			assert(numcount.size() == 5);
		return 2 * rolevalue + getnumpower(numcount);
	}
	Poker(vector<Card>_cards) :cards(_cards) {}
};
map<char, int>nummp =
{
	{ 'A',1 },
	{ '2',2 },
	{ '3',3 },
	{ '4',4 },
	{ '5',5 },
	{ '6',6 },
	{ '7',7 },
	{ '8',8 },
	{ '9',9 },
	{ 'T',10 },
	{ 'J',11 },
	{ 'Q',12 },
	{ 'K',13 },

};
map<char, int>typemp =
{
	{ 'S',3 },
	{ 'H',2 },
	{ 'D',1 },
	{ 'C',0 },
};
template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ???
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ???
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ??¢
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}

long long int getmaxpower(const vector<Card>&cards) {
	vector<int>order(7);
	iota(order.begin(), order.end(),0);
	long long int maxpower = -1;
	do {
		vector<Card>usecards;
		for (int i = 0; i < 5; ++i) {
			usecards.push_back(Card(cards[order[i]]));
		}
		Poker poker(usecards);
		maxpower = max(maxpower, poker.getpower());
	} while (next_combination(order.begin(), order.begin() + 5, order.end()));
	return maxpower;
}
int main() {
	while(1) {
		vector<vector<Card>>hands(2,vector<Card>(2));
		vector<Card>frops(3);
		vector<vector<bool>>used(4, vector<bool>(13));
		{
			vector<vector<string>>handsts(2, vector<string>(2));
			cin >> handsts[0][0];
			if (handsts[0][0] == "#")return 0;
			cin >> handsts[0][1];
			cin >> handsts[1][0];
			cin >> handsts[1][1];
			vector<string>fropsts(3);
			cin >> fropsts[0] >> fropsts[1] >> fropsts[2];
			for (int i = 0; i < 2; ++i) {
				for (int j = 0; j < 2; ++j) {
					const int type = typemp[handsts[i][j][0]];
					const int num = nummp[handsts[i][j][1]];
					hands[i][j] = Card(type, num);
					used[type][num - 1] = true;
				}
			}
			for (int i = 0; i < 3; ++i) {
				const int type = typemp[fropsts[i][0]];
				const int num = nummp[fropsts[i][1]];
				frops[i] = Card(type, num);
				used[type][num - 1] = true;
			}
		}
		ld per = 0;
		for (int one = 0; one < 52; ++one) {
			Card onec = Card(one % 4, one / 4+1);
			for (int two = one + 1; two < 52; ++two) {
				Card twoc = Card(two % 4, two / 4+1);
				if (used[one % 4][one / 4])continue;
				if (used[two % 4][two / 4])continue;
				vector<Card>mycards(hands[0]);
				vector<Card>opcards(hands[1]);
				mycards.insert(mycards.end(), frops.begin(), frops.end());
				opcards.insert(opcards.end(), frops.begin(), frops.end());
				mycards.emplace_back(onec); mycards.emplace_back(twoc);
				opcards.emplace_back(onec); opcards.emplace_back(twoc);
				const long long int myp(getmaxpower(mycards));
				const long long int opp(getmaxpower(opcards));
				if (myp > opp) {
					per++;
				}
				else {
					per--;
					per++;
				}
			}
		}
		per /= (45 * 44/2);
		cout << setprecision(22) << fixed << per << endl;
	}
	return 0;
}

Measured memory_bytes: 3204