INPUT column value can be A or B or C
REQUIRED OUTPUT value based on condition as follows
condition(1)if INPUT value A then REQUIRED OUTPUT A
condition(2)if INPUT value C then REQUIRED OUTPUT C
condition(3.i)if INPUT value B and B present after C then REQUIRED OUTPUT C
condition(3.ii.a)if INPUT value B and B present after A and upto 3 times B then REQUIRED OUTPUT A
condition(3.ii.b)if INPUT value B and B present after A and after 3 times B then REQUIRED OUTPUT C