Code:
Input
m1,s1,x1,x1
m1,s2,x2,x2
m1,s3,x2,x2
m1,s4,x1,x1
m1,s5,x1,x2
m2,s1,y2,y2
m2,s2,y1,y1
m2,s3,y2,y1
m2,s4,y2,y1
m2,s5,y1,y1
m3,s1,y2,y2
m3,s2,y2,y2
m3,s3,y2,y1
m3,s4,y2,y1
m3,s5,y1,y1
Output
m1,s1,a
m1,s2,b
m1,s3,b
m1,s4,a
m1,s5,c
m2,s1,a
m2,s2,b
m2,s3,c
m2,s4,c
m2,s5,b