sherlock find piece encrypt datum think useful catch Moriarty the encrypted data consist integer l r he notice integer hexadecimal formHe take integer l r perform follow operation he list distinct digit present give number for example 101416 list digit 104 then sum respective power digit list step like example sum2120241910 he change initial number apply bitwise xor initial number sum Example note xor binary notation one example integer 1e sum sum21214 Letters b c d e f denote hexadecimal digit 10 11 12 13 14 15 respertivelysherlock want count number range l r inclusive decrease application step he want answer q query different l r