N = gets.to_i S = gets.chomp T = gets.chomp Q = gets.to_i state = S <=> T idx_list = [*0..N] nums = Array.new(N) { Array.new(2, 0) } stacked = Hash.new(false) N.times do |i| nums[i][0] = S[i].to_i nums[i][1] = T[i].to_i stacked[i] = true end Q.times do c, x, y = gets.chomp.split x = x.to_i - 1 y = y.to_i if !stacked[x] idx = idx_list.bsearch_index { |i| i > x } if idx.nil? idx_list << x else idx_list.insert(idx, x) end end if c == 'S' nums[x][0] = y else nums[x][1] = y end until idx_list.empty? i = idx_list.first state = nums[i][0] <=> nums[i][1] break if state != 0 stacked[i] = false idx_list.shift end if idx_list.empty? state = 0 end case state when -1 puts '<' when 0 puts '==' when 1 puts '>' end end