from collections import deque M = [ [ deque([ 84, 72, 58, 51]) , lambda old: old * 3 , lambda x: 7 if divmod(x,13)[1] else 1 ,0 ],[ deque([ 88, 58, 58 ]) , lambda old: old + 8 , lambda x: 5 if divmod(x,2)[1] else 7 ,0 ],[ deque([ 93, 82, 71, 77, 83, 53, 71, 89]) , lambda old: old * old , lambda x: 4 if divmod(x,7)[1] else 3 ,0 ],[ deque([ 81, 68, 65, 81, 73, 77, 96]) , lambda old: old + 2 , lambda x: 6 if divmod(x,17)[1] else 4 ,0 ],[ deque([ 75, 80, 50, 73, 88]) , lambda old: old + 3 , lambda x: 0 if divmod(x,5)[1] else 6 ,0 ],[ deque([ 59, 72, 99, 87, 91, 81]) , lambda old: old * 17 , lambda x: 3 if divmod(x,11)[1] else 2 ,0 ],[ deque([ 86, 69]) , lambda old: old + 6 , lambda x: 0 if divmod(x,3)[1] else 1 ,0 ],[ deque([ 91]) , lambda old: old + 1 , lambda x: 5 if divmod(x,19)[1] else 2 , 0 ] ]