#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

pair<int, vector<int>>score(vector<string>s) {
	for (auto &i : s) {
		if (i[1] == 'A')i[1] = '0' + 14;
		if (i[1] == 'K')i[1] = '0' + 13;
		if (i[1] == 'Q')i[1] = '0' + 12;
		if (i[1] == 'J')i[1] = '0' + 11;
		if (i[1] == 'T')i[1] = '0' + 10;
		swap(i[1], i[0]);
	}
	sort(s.rbegin(), s.rend());
	for (auto &i : s)swap(i[1], i[0]);
	pair<int, vector<int>>ret;
	for (int i = 0; i < 7; i++) {
		for (int j = i + 1; j < 7; j++) {
			for (int k = j + 1; k < 7; k++) {
				for (int l = k + 1; l < 7; l++) {
					for (int m = l + 1; m < 7; m++) {
						{//no
							ret = max(ret, { 1,{ s[i][1] - '0',s[j][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
						}
						{//1p
							if (s[i][1] == s[j][1]) {
								ret = max(ret, { 2,{ s[i][1] - '0',s[i][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[j][1] == s[k][1]) {
								ret = max(ret, { 2,{ s[j][1] - '0',s[j][1] - '0' ,s[i][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[k][1] == s[l][1]) {
								ret = max(ret, { 2,{ s[k][1] - '0',s[k][1] - '0' ,s[i][1] - '0', s[j][1] - '0',s[m][1] - '0' } });
							}
							if (s[l][1] == s[m][1]) {
								ret = max(ret, { 2,{ s[l][1] - '0',s[l][1] - '0' ,s[i][1] - '0', s[j][1] - '0',s[k][1] - '0' } });
							}
						}
						{//2p
							if (s[i][1] == s[j][1] && s[k][1] == s[l][1]) {
								ret = max(ret, { 3,{ s[i][1] - '0',s[j][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[i][1] == s[j][1] && s[l][1] == s[m][1]) {
								ret = max(ret, { 3,{ s[i][1] - '0',s[j][1] - '0' ,s[l][1] - '0', s[m][1] - '0',s[k][1] - '0' } });
							}
							if (s[j][1] == s[k][1] && s[l][1] == s[m][1]) {
								ret = max(ret, { 3,{ s[j][1] - '0',s[k][1] - '0' ,s[l][1] - '0', s[m][1] - '0',s[i][1] - '0' } });
							}
						}
						{//3c
							if (s[i][1] == s[k][1]) {
								ret = max(ret, { 4,{ s[i][1] - '0',s[i][1] - '0' ,s[i][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[j][1] == s[l][1]) {
								ret = max(ret, { 4,{ s[j][1] - '0',s[j][1] - '0' ,s[j][1] - '0', s[i][1] - '0',s[m][1] - '0' } });
							}
							if (s[k][1] == s[m][1]) {
								ret = max(ret, { 4,{ s[k][1] - '0',s[k][1] - '0' ,s[k][1] - '0', s[i][1] - '0',s[j][1] - '0' } });
							}
						}
						{//s
							if (s[i][1] == s[j][1] + 1 && s[i][1] == s[k][1] + 2 && s[i][1] == s[l][1] + 3 && s[i][1] == s[m][1] + 4) {
								ret = max(ret, { 5,{ s[i][1] - '0',s[j][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[i][1] == '0' + 14 && s[j][1] == '5' && s[k][1] == '4' && s[l][1] == '3'&&s[m][1] == '2') {
								ret = max(ret, { 5,{ s[j][1] - '0',s[j][1] - '0' ,s[j][1] - '0', s[j][1] - '0',s[i][1] - '0' } });
							}

						}
						{//f
							if (s[i][0] == s[j][0] && s[i][0] == s[k][0] && s[i][0] == s[l][0] && s[i][0] == s[m][0]) {
								ret = max(ret, { 6,{ s[i][1] - '0',s[j][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
						}
						{//fh
							if (s[i][1] == s[k][1] && s[l][1] == s[m][1]) {
								ret = max(ret, { 7,{ s[i][1] - '0',s[j][1] - '0' ,s[k][1] - '0', s[l][1] - '0',s[m][1] - '0' } });
							}
							if (s[i][1] == s[j][1] && s[k][1] == s[m][1]) {
								ret = max(ret, { 7,{ s[k][1] - '0',s[l][1] - '0' ,s[m][1] - '0', s[i][1] - '0',s[j][1] - '0' } });
							}
						}
						{//4c
							if (s[i][1] == s[l][1]) {
								ret = max(ret, { 8,{s[i][1] - '0',s[i][1] - '0' ,s[i][1] - '0', s[i][1] - '0',s[m][1] - '0' } });
							}
							if (s[j][1] == s[m][1]) {
								ret = max(ret, { 8,{ s[j][1] - '0',s[j][1] - '0' ,s[j][1] - '0', s[j][1] - '0',s[i][1] - '0' } });
							}
						}
						{//sf
							if (s[i][0] == s[j][0] && s[i][0] == s[k][0] && s[i][0] == s[l][0] && s[i][0] == s[m][0] && s[i][1] - s[m][1] == 4) {
								ret = max(ret, { 9,{s[i][1] - '0',s[j][1] - '0', s[k][1] - '0', s[l][1] - '0', s[m][1] - '0' } });
							}
							if (s[i][0] == s[j][0] && s[i][0] == s[k][0] && s[i][0] == s[l][0] && s[i][0] == s[m][0] && s[i][1] == '0' + 14 && s[j][1] == '0' + 5) {
								ret = max(ret, { 9,{ s[j][1] - '0',s[k][1] - '0', s[l][1] - '0', s[m][1] - '0'} });
							}
						}
						{//lsf
							if (s[i][0] == s[j][0] && s[i][0] == s[k][0] && s[i][0] == s[l][0] && s[i][0] == s[m][0] && s[i][1] == '0' + 14 && s[j][1] == '0' + 13 && s[k][1] == '0' + 12 && s[l][1] == '0' + 11 && s[m][1] == '0' + 10) {
								ret = max(ret, { 10,{14,13,12,11,10} });
							}
						}
					}
				}
			}
		}
	}
///	for (auto i : s) {
///		cout << i << " ";
///	}
///	cout << endl;
///	cout << ret.first << endl;
///	for (auto i : ret.second)cout << i << " ";
///	cout << endl;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	vector<string>s(7);
	vector<string>su = { "S","H","D","C" };
	vector<string>num = { "2", "3", "4", "5", "6", "7", "8", "9","T","J","Q","K","A" };
	vector<string>t;
	for (auto i : su) {
		for (auto j : num) {
			t.push_back(i + j);
		}
	}
	cin >> s[0];
	while (s[0]!="#") {
		for (int i = 1; i < 7; i++)cin >> s[i];
		long double win = 0;
		for (auto i : t) {
			bool ed = false;
			for (int j = 0; j < 7; j++) {
				ed |= s[j] == i;
			}
			if (ed)continue;
			for (auto j : t) {
				if (i == j)continue;
				ed = false;
				for (int k = 0; k < 7; k++) {
					ed |= s[k] == j;
				}
				if (ed)continue;
				vector<string>a;
				a.push_back(s[0]);
				a.push_back(s[1]);
				a.push_back(s[4]);
				a.push_back(s[5]);
				a.push_back(s[6]);
				a.push_back(i);
				a.push_back(j);
				vector<string>b;
				b.push_back(s[2]);
				b.push_back(s[3]);
				b.push_back(s[4]);
				b.push_back(s[5]);
				b.push_back(s[6]);
				b.push_back(i);
				b.push_back(j);
				auto as = score(a);
				auto bs = score(b);
				if (as > bs)win++;
			}
		}
		cout << setprecision(20) << win / 45 / 44 << endl;
		cin >> s[0];
	}

}


Measured memory_bytes: 3328