I have 2 dimensional array and i should compare the elements with one another and add it into an another array!!!!!!!

The array i am using is

a x a p m

m m m m c

c p d y a

I should compare this array elements.

I tried comparing column by column but i am getting the solution.

Can some one help me with this?