# given an input that is the IP output of sample_once, and a base address for the program, calculates the relative IPs.
from__future__importprint_functionimportsysbase=int(sys.argv[1],16)ips=[]forlineinsys.stdin.readlines():fortokeninline.split():try:ips.append(int(token.strip(),16))exceptValueError:passforipinips:print(hex(ip-base))