Constraint 2d array using SUM operator

Hi, I am trying to solve this question with sum() operator. Tried below, but did not work.

Write a constraint to generate mxn(m,n<-9) matrix such that all rows and collumns have a unique numbers between 1-9 USINg SUM operator

I was able to do it in other ways, but curious if we can achieve it with sum()

module top;

class A;
rand bit [7:0] a

;
rand int rows,cols;
constraint arr_c {

rows<=9;
cols<=9;
a.size() <= rows;
a[i].size() == cols;

foreach(a[i,j]) {
  a[i].sum() with ((item==a[i])?1:0) == 1;////each item repeats once
 // a.sum with (item.index(2)==j) ? (item==a[i,j]?1:0) :0) ==1;//THis doesnt work

}
}
endclass
A a_h;
initial begin
repeat (10) begin
a_h = new();
assert(a_h.randomize() );
$display(“***************************** list =  %0p ****************************************”, a_h.a);
end
end
endmodule