#!/usr/bin/perl
#
# This code is public domain code.

$seq = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-';

sub decode
{
    ($encoded) = @_;
    @s = map { index($seq,$_); } split(//,$encoded);
    $l = ($#s+1) % 4;
    if ($l)
    {
	if ($l == 1)
	{
	    print "Error!";
	    return;
	}
	$l = 4-$l;
	$#s += $l;
    }
    $r = '';
    while ($#s >= 0)
    {
	$n = (($s[0] << 6 | $s[1]) << 6 | $s[2]) << 6 | $s[3];
	$r .=chr(($n >> 16) ^ 67) .
	     chr(($n >> 8 & 255) ^ 67) .
	     chr(($n & 255) ^ 67);
	@s = @s[4..$#s];
    }
    $r = substr($r,0,length($r)-$l);
    return $r;
}


while (1) {
    $s = <STDIN>;
    chomp($s);
    @fields = split(/\./,$s);
    @results = map(decode($_), @fields[1..$#fields]);
    if ($#results == 2)
    {
        print "Serial: $results[0]\n";
	print "Type: $results[1]\n";
	print "Code: $results[2]\n";
    }
    else
    {
	print join("\n",@results);
    }
}