/* (c) 2012 by Thomas Arend, 2012/10/25
 *
 *
 * Purpose: Decode parseInt encoded input file
 * Parameter: radix for parseInt
 * Input: parseInt encoded file
 * Output: decodet file
 *

 * The Toolkit Blackhole codes a Java-Script
 * in the attribute values of a tag.
 * Every two characters are interpreted as an integer and 
 * parsed with parseInt and fromCharCode into an new character
 * 
 * The radix can be guessed with the program piRadix
 
 * $Id: $
 * $Log:$
 */
#include <stdlib.h>
#include <stdio.h>
#include <string>

using namespace std;

int digittoint ( int digit ){

  if ('0' <= digit && digit <= '9')
    return (digit - '0');
  else if ('a' <= digit && digit <= 'z' )
    return (digit -'a' + 10);
  else
    return 255;

}

int char2toint ( int z1, int z2, int radix) {

  return (digittoint(z1) * radix + digittoint(z2)) ;

}


int main ( int argc, char *argv[ ])
{

  int character1 = 0;
  int character2 = 0 ;
  int code  = 0;
  int radix = 16 ;

  if (argc > 1 ) {
    radix = atoi(argv[1]);
  }
  else {
    radix = 16;
  }

  while (( character1 = getchar()) != EOF ) {

    if ( (character2 = getchar()) == EOF ) break;

    code = char2toint ( character1, character2, radix );

    if ( code < 256 ) {
      putchar(code);
    } else {
        putchar(code >> 8);
        putchar(code & 256);
    }

  }
  printf ( "\n" ) ;
  return 0;

}