set a 0 while 1 { switch [gets stdin] {i {incr a} s {set a [expr {$a*$a}]} d {if {$a>0} {incr a -1}} o {puts $a} h {exit}} if {$a==256} {set a 0} }