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) } N.times do |i| nums[i][0] = S[i].to_i nums[i][1] = T[i].to_i end Q.times do c, x, y = gets.chomp.split x = x.to_i - 1 y = y.to_i idx = idx_list.bsearch_index { |i| i > x } if idx.nil? idx_list << x else idx_list.insert(idx, x) 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 idx_list.shift end if idx_list.empty? state = 0 end case state when -1 puts '<' when 0 puts '==' when 1 puts '>' end end