Hi Yusha, There are multiple ways to do that. One way is using randi to generate each column with the appropriate constraints and concatenate them later as shown below:
z=randi([0 4],1000,1);
x=randi([0 1],1000,1);
randomPairs = [z x];
Let me know if this helps.
-Prasanth