Barcode app to evenly distribute products to stores

hello, Im trying to build an app to generate a barcode for products in my friend store. For example:

I have 4 stores and each store has different profit margins for the same product. The barcode of a product has 4 variables in it : model number, colour, size and store id.
I have received 100 pieces of a product and I want to generate barcodes for it one by one. So for the first piece out of the box, I’ll input the model number, colour and size and assign it to store 1. The next item with same model number, color and size will go to store 2, then store 3, 4 and finally when all stores have 1 item of with the same attributes I will put the 5th item with same attributes in store 1 and so on.

number of stores: 4
number of pieces: 100
number of model numbers: 3
number of colours: unknown
number of sizes: unknown

I want to distribute the products evenly among 4 stores, one by one.