Brooks scores 27 as Grizzlies battle past Knicks 127-106