class No26 attr_accessor :currect, :test_case, :cups def initialize @currect, @test_case = gets.chomp.to_i, gets.chomp.to_i @cups = [0, 0, 0] @cups[@currect - 1] = 1 end def swap!(ary, idx1, idx2) ary[idx1], ary[idx2] = ary[idx2], ary[idx1] ary end def run for i in 0...@test_case do location1, location2 = gets.chomp.split.map(&:to_i) self.swap!(@cups, location1 - 1, location2 - 1) end end end no26 = No26.new no26.run no26.cups.each.with_index{|value, element| puts element + 1 if value == 1}