Combinations general

we are given a 2d array of numbers as a input
suppose each row in it is a different group,
now we are given a input k,
we have to select atmost k elements from that 2d array satisfying the condition that if an element is selected from a paticular row then we can’t select again from that row, so clearly k must be less than number of rows, how many combinations are possible
what could be the formula here

@sktg99
Let no of rows = row
Let no of cols = col

We have to pick k rows out of total rows.
To choose k rows out of ‘row’ , the formula is C(row,k) where C( ) is the combination function.
Also , we can choose any of the ‘col’ elements out of the selected rows.

Final answer = C(row,k) * col = ( (row)! / (row - k)! * k ! ) * col

that’s right but sorry I forgot to mention that the number of columns for each row is different that means first row can have different number of elements than others, how will we do then? actually this question was different so I asked you relating with a 2d array that has constant columns but the case I’m asking it’s not, can u pls tell the answer now