UVA Solutions 10055 – Hashmat the Brave Warrior

Note: You have to take long long as it is wanted in the description 2^32