2D Array Column Sum Constraint Failing

I am trying to constrain the sum of each column of a 2D array to certain values provided by another array but I am getting an error “cannot mix packed and unpacked types in this operation”. I think I am using unpacked arrays all along in my example shown below so can someone please explain where exactly I am making a mistake here.

class sample;
  
  rand int arr[2][4];
  int a[4] = '{9,7,6,5};
  
  constraint x{
  
    foreach(arr[i,j]){
      arr[i][j]>0;
      arr[i][j]<10;
      
}}
 
      constraint xy{
      
       foreach(a[i]){
      
         (arr.sum with ((item.index(2)==i)?item:0)) == a[i];
      }
      
      }
  endclass

module tb;
  
  sample s=new();
  
  initial begin
    s.randomize();
    $display("%p",s.arr);
  end
  endmodule

This link should help, as well as the links on that page

My solutions works fine in VCS but not in Questa.

Your solution does not work on 3 out of 4 tools on EDA playground. Try the example on this reply: 2D array constraint randomization - #9 by dave_59