 1, acc = 0;
	while(t)
		acc += sft * (t & 0x3), t >>= 2, sft *= 3;
	return acc;
}

trint16_t
bin2ter(int n)
{
	trint16_t sft = 0, acc = 0;
	while(n > 0)
		acc |= (n % 3) << sft, n /= 3, sft += 2;
	return acc;
}

trint16_t
hep2ter(char *str)
{
	char c;
	trint16_t acc = 0;
	while((c = *str++))
		acc <<= 6, acc |= bin2ter(c ? (c - 'A') + 1 : 0);
	return acc;
}

void
print_heptavintimal(trint16_t n)
{
	int i;
	for(i = 4; i > -1; --i) {
		int t = ter2bin((n >> (i * 6)) & 0x3f);
		putchar(t ? '@' + t : '0');
	}
