Validates row and column indexes.