package main;import."fmt";func main(){for{s,t:="","";Scan(&s,&t);Print((t+s)[(s[1]^s[2]^15)/15*5]&15)}}