Modified program to handle the input of rows and columns and throw an exception when the inputs exceed the maximum allowed.