from collections import deque M = [ [ deque([ 79, 98 ]) , lambda old: old * 19 , lambda x: 3 if divmod(x,23)[1] else 2 ,0 ],[ deque([ 54, 65, 75, 74 ]) , lambda old: old + 6 , lambda x: 0 if divmod(x,19)[1] else 2 ,0 ],[ deque([ 79, 60, 97 ]) , lambda old: old * old , lambda x: 3 if divmod(x,13)[1] else 1 ,0 ],[ deque([ 74 ]) , lambda old: old + 3 , lambda x: 1 if divmod(x,17)[1] else 0 ,0 ] ]