array = [] gets.to_i.times do array << gets.split end puts (array = array.transpose.map { |val| val.delete('-'); val.uniq }).count(['nyanpass']) == 1 ? array.index(['nyanpass']) + 1 : -1