#include <stdio.h>
void print(unsigned x)
{
int i;
for(i = 1; i <= 32; i++, x <<= 1)
{
putchar(x
& 0x80000000 ? '1' : '0'); }
}
int main(void) {
const char* string = "ABcd1234";
unsigned out=0;
char x;
while((x = *string++))
{
unsigned value;
if (x < '0') goto invalid;
if (x < '9' + 1) { value = x - '0'; goto valid; }
if (x < 'A') goto invalid;
if (x < 'F' + 1) { value = x - 'A' + 10; goto valid; }
if (x < 'a') goto invalid;
if (x < 'f' + 1) { value = x - 'a' + 10; goto valid; }
goto invalid;
valid:
out = (out << 4) | value;
}
print(out);
return 0;
invalid: return 1;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHByaW50KHVuc2lnbmVkIHgpCnsKCWludCBpOwoJZm9yKGkgPSAxOyBpIDw9IDMyOyBpKyssIHggPDw9IDEpCgl7CgkJcHV0Y2hhcih4ICYgMHg4MDAwMDAwMCA/ICcxJyA6ICcwJyk7CgkJaWYgKChpICYgMykgPT0gMCkgcHV0Y2hhcignICcpOwoJfQp9CgppbnQgbWFpbih2b2lkKSB7Cgljb25zdCBjaGFyKiBzdHJpbmcgPSAiQUJjZDEyMzQiOwogICAgdW5zaWduZWQgb3V0PTA7CiAgICBjaGFyIHg7CiAgICB3aGlsZSgoeCA9ICpzdHJpbmcrKykpCiAgICB7CiAgICAJdW5zaWduZWQgdmFsdWU7CiAgICAgICAgaWYgKHggPCAnMCcpIGdvdG8gaW52YWxpZDsKICAgICAgICBpZiAoeCA8ICc5JyArIDEpIHsgdmFsdWUgPSB4IC0gJzAnOyBnb3RvIHZhbGlkOyB9CiAgICAgICAgaWYgKHggPCAnQScpIGdvdG8gaW52YWxpZDsKICAgICAgICBpZiAoeCA8ICdGJyArIDEpIHsgdmFsdWUgPSB4IC0gJ0EnICsgMTA7IGdvdG8gdmFsaWQ7IH0KICAgICAgICBpZiAoeCA8ICdhJykgZ290byBpbnZhbGlkOwogICAgICAgIGlmICh4IDwgJ2YnICsgMSkgeyB2YWx1ZSA9IHggLSAnYScgKyAxMDsgZ290byB2YWxpZDsgfQogICAgICAgIGdvdG8gaW52YWxpZDsKICAgIHZhbGlkOgogICAgICAgIG91dCA9IChvdXQgPDwgNCkgfCB2YWx1ZTsKICAgIH0KICAgIHByaW50KG91dCk7CiAgICByZXR1cm4gMDsKICAgIGludmFsaWQ6IHJldHVybiAxOwp9Cg==