9 hats drives me crazy already but more 18 means 27 in total WTH
but also it's mean 1 person couldn't have all hats
if they keep all item

because class*3+9+18>50