Talia buy abandon house outskirt Jakarta the house nice long yard represent onedimensional grid contain 1 time n cell to beautify house Talia going build terrace yard tiling cell each cell yard contain soil represent character rock represent character 50 cell contain rocksbee superstitious person Talia want tile terrace mystical tile power repel ghost there type mystical tile type1 cover 1 time 1 cell place soil cell type2 cover 1 time 2 cell place consecutive soil cell type3 cover 1 time 3 cell place consecutive soilrocksoil cell each tile type1 Type2 Type3 power repel G_1 G_2 G_3 ghost day respectively there mystical rule follow power effective there overlap tile ie cell cover tile there k tile type1 limitation tile type2 Type3 Talia scare ghost terrace tile mystical tile able repel ghost possible help Talia find maximum number ghost repel day terrace Note Talia need tile cell yard long number ghost repel terrace maximum