Let the number of boxes be x. So the number of pencils in each box would be 72/x, the number of files 60/x and the number of notebooks 54/x. So x must divide in each case to give a whole number. The highest number it could be is 6, because 6 is the HCF for 72, 60 and 54.
Number in each box is: 12 pencils, 10 files, and 9 notebooks. 31 items in each box means 6*31=186 items in 6 boxes=72+60+54.