import List main=interact$f[]2.map words.lines f x i t|i<0=sort x>>=show.last|0<1=f([61-m,l-48]:[a+61-m:s|a:s<-x,a/=0])(n-63)t where[l,m,n]=map fromEnum$t!!sum(1:[s|[0,s]<-x])!!i