q = gets.to_i

oldies  = []
newies  = {}
changes = {}

q.times do
    old, new = gets.chomp.split

    oldies.push(old) if changes[old] == nil && newies[old] == nil
    changes[old] = new
    newies[new]  = true
end

puts oldies.size
oldies.each do |old|
    new = changes[old]
    while changes[new] != nil
        new = changes[new]
    end

    puts "#{old} #{new}"
end

# @snippet<contest.rb#0.0.6:namespace.rb>
module Solution; end
# @snippet<contest.rb#0.0.6:header.rb>
require "scanf"
# @snippet<contest.rb#0.0.6:runner.rb>
class Solution::Runner

  def self.run(input_format, input_stream = STDIN, output_stream = STDOUT, &block)
    Solution::Solver.new(input_format, input_stream, output_stream) do
      input do |args|
        if block.nil?
          output solve(*args)
        else
          output block.call(*args)
        end
      end
    end
  end

end
# @snippet<contest.rb#0.0.6:solver.rb>
class Solution::Solver

  attr_reader :input_format
  attr_reader :input_stream
  attr_reader :output_stream

  def initialize(new_input_format, new_input_stream, new_output_stream, &block)
    @input_format = new_input_format
    @input_stream = new_input_stream
    @output_stream = new_output_stream

    instance_eval(&block) if block_given?
  end

  def input
    while s = gets
      break if s.nil?
      s.scanf(input_format) do |*args|
        yield(*args)
      end
    end
  end

  def output(res)
    puts res.size
    res.each do |key, value|
      puts "#{key} #{value}"
    end
  end

end
# @snippet<contest.rb#0.0.6:main.rb>

require "set"

class Disj

  attr_reader :parent
  attr_reader :root
  attr_reader :last_name

  def initialize
    @last_name = {}
    @parent = {}
    @root = Set.new
  end

  def size
    @root.size
  end

  def find(name)
    if parent[name].nil?
      name
    else
      find(parent[name])
    end
  end

  def parent?(name)
    find(name) === name
  end

  def update(old_name, new_name)
    if parent?(old_name)
      root.add old_name
    end
    last_name[find(old_name)] = new_name
    parent[new_name] = find(old_name)
    self
  end

  def each
    root.each do |name|
      yield name, last_name[name]
    end
  end

end

input_format = "%d" # scanf(input_format)
Solution::Runner.run(input_format) do |q|
  (1..q).to_a.map do
    old, new = gets.split
    {:new => new, :old => old, }
  end.inject(Disj.new) do |disj, info|
    disj.update info[:old], info[:new]
  end
end

n = gets.to_i

h = Hash.new

n.times do
    old_handle, new_handle = gets.split(' ')
    if h[old_handle].nil? then
        h[new_handle] = old_handle
    else
        h[new_handle] = h[old_handle]
        h.delete(old_handle)
    end
end

print "#{h.length}\n"
h.each do |k, v|
    print "#{v} #{k}\n"
end

q = gets.to_i

users = {}

for s in STDIN.each_line.take q
  old, new = s.split " "

  if users.has_value? old
    k = users.key(old)
    users[k] = new
  else
    users = users.merge!({old => new})
  end
end

puts users.length

users.each do |k, v|
  puts "#{k} #{v}"
end

pa=Array.new
ha=Hash.new  #ruby的哈希
hb=Hash.new  #ruby的哈希

n=gets.to_i
for i in 1..n
  str=gets.to_s
  pa=str.split
  stra=pa[0]
  strb=pa[1]
  ha[stra]=strb
end
#p ha

ha.each{|key,value|
  stt=key
  while ha[stt]!=nil
    stb=stt
    stt=ha[stt]
    ha.delete(stb)
  end
  hb[key]=stt
}
#p hb

puts hb.length
hb.each{|key,value|
  puts"#{key} #{value}"  #输出格式控制
}

# $f = File.open('input.txt', 'r')
$f = STDIN

def read_line
  $f.gets.chomp.split
end

def read_input(n)
  hash = {}
  n.times do
    sa, sb = read_line
    change = hash.key(sa) || sa

    hash[change] = sb
  end
  hash
end

def output(hash)
  puts hash.size
  hash.each do |k, v|
    puts "#{k} #{v}"
  end
end

def solve(n)
  output read_input(n)
end

while str = $f.gets
  n = str.chomp.to_i
  solve(n)
end

# f=File.new("out.txt","w")
# fi=File.open("in.txt","r")

n=gets
#f.puts(n)
db=Array.new;
n.to_i.times do | |
  s=gets
  names=s.split
  b=1
  if db.empty?
    db.push(Array.new)
    db.last.push(names[0])
    db.last.push(names[1])
  else
    db.each do |i|
      if i.last==names[0]
        i.push(names[1])
        b=0
      end
    end
    if b==1
      db.push(Array.new)
      db.last.push(names[0])
      db.last.push(names[1])
    end
  end

end

puts db.size
db.each do |i|
print i.first
print " "
puts i.last
end

q = gets.chomp.to_i
queries = []
q.times { queries << gets.chomp.split }

hash = Hash.new { |h, k| h[k] = [] }
queries.each do |old_name, new_name|
  root = hash.keys.select { |key| hash[key].last == old_name }.first
  if root.nil?
    hash[old_name] << new_name
  else
    hash[root] << new_name
  end
end

puts hash.keys.length
hash.keys.each { |key| puts "#{key} #{hash[key].last}" }

n=gets.to_i
s=[]
cnt=0
n.times do
  s << gets.split(' ').map{|x| x.to_s}
  s.flatten!
  for i in 0...s.size-2
    if s[-2] == s[i] && i%2==1
      cnt+=1
      s[i]=s[-1]
      s.delete_at(-2)
      s.delete_at(-1)
    end
  end
end
i=0
puts n-cnt
while i < s.size
  print s[i]+" "+s[i+1]
  puts
  i+=2
end

q = STDIN.gets.to_i

users = {}
q.times do
  old, new = STDIN.gets.split(' ')

  if users.values.include?(old)
    initial = users.key(old)
    users[initial] = new
  else
    users[old] = new
  end

end

puts users.keys.count
users.each_pair do |old, new|
  puts "#{old} #{new}"
end

n = gets.to_i
names = {}
n.times do |i|
  before, after = gets.chomp.split
  if names[before] != nil
    names[after] = names[before]
    names.delete(before)
  else
    names[after] = before
  end
end

puts names.length
names.each do |after, before|
  puts [before, after].join(" ")
end

h = {}
n = gets.to_i
n.times{
    a,b = gets.split
    if h[a]
        h[b] = h[a]
        h.delete(a)
    else
        h[b] = a
    end
}
puts h.length
h.each { |a,b| puts "#{b} #{a}"}

q = gets.to_i

users = Hash.new

q.times do
    o, n = gets.split(" ")
    if users[o].nil? then
        users[n] = o
    else
        users[n] = users[o]
        users.delete(o)
    end
end

print "#{users.length}\n"
users.each do |v, k|
    print "#{k} #{v}\n"
end

n = gets.to_i
hash = {}
n.times do
	old,new = gets.split.map(&:chomp)
	if hash.key?(old)
		hash[new] = hash[old]
		hash.delete(old)
	else
		hash[new] = old
	end
end
p hash.length
hash.invert.sort_by{|key,val| key}.each{|val| puts "#{val[0]} #{val[1]}"}

#!/usr/bin/ruby

input_line = gets
amount = input_line.to_i

users = Hash.new
counter = 0
while (counter < amount)  do
    counter +=1
    input_line = gets.split(' ')
    if (users.has_value? input_line[0])
        users[users.key(input_line[0])] = input_line[1]
    else
        users[input_line[0]] = input_line[1]
    end
end

puts users.size

users.each_key do |key|
        puts key+' ' + users[key]
end

# @snippet<contest.rb#0.0.6:namespace.rb>
module Solution; end
# @snippet<contest.rb#0.0.6:header.rb>
require "scanf"
# @snippet<contest.rb#0.0.6:runner.rb>
class Solution::Runner

  def self.run(input_format, input_stream = STDIN, output_stream = STDOUT, &block)
    Solution::Solver.new(input_format, input_stream, output_stream) do
      input do |args|
        if block.nil?
          output solve(*args)
        else
          output block.call(*args)
        end
      end
    end
  end

end
# @snippet<contest.rb#0.0.6:solver.rb>
class Solution::Solver

  attr_reader :input_format
  attr_reader :input_stream
  attr_reader :output_stream

  def initialize(new_input_format, new_input_stream, new_output_stream, &block)
    @input_format = new_input_format
    @input_stream = new_input_stream
    @output_stream = new_output_stream

    instance_eval(&block) if block_given?
  end

  def input
    while s = gets
      break if s.nil?
      s.scanf(input_format) do |*args|
        yield(*args)
      end
    end
  end

  def output(res)
    puts res.size
    res.each do |key, value|
      puts "#{key} #{value}"
    end
  end

end
# @snippet<contest.rb#0.0.6:main.rb>

require "set"

class Disj

  attr_reader :parent
  attr_reader :root
  attr_reader :last_name

  def initialize
    @last_name = {}
    @parent = {}
    @root = Set.new
  end

  def size
    @root.size
  end

  def find(name)
    if parent[name].nil?
      name
    else
      find(parent[name])
    end
  end

  def parent?(name)
    find(name) === name
  end

  def update(old_name, new_name)
    if parent?(old_name)
      root.add old_name
    end
    last_name[find(old_name)] = new_name
    parent[new_name] = find(old_name)
  end

  def each
    root.each do |name|
      yield name, last_name[name]
    end
  end

end

input_format = "%d" # scanf(input_format)
Solution::Runner.run(input_format) do |q|
  disj = Disj.new

  list = (1..q).to_a.map do
    old, new = gets.split
    {:new => new, :old => old, }
  end

  list.inject(Set.new) do |set, info|
    disj.update info[:old], info[:new]
  end

  disj
end

q = gets.to_i

users = Hash.new

q.times do
    o, n = gets.split(" ")
    p users[o]
    if users[o].nil? then
        users[n] = o
    else
        users[n] = users[o]
        users.delete(o)
    end
end

print "#{users.length}\n"
users.each do |v, k|
    print "#{k} #{v}\n"
end

pa=Array.new
ha=Hash.new  #ruby的哈希
hb=Hash.new  #ruby的哈希

n=gets.to_i
for i in 1..n
  str=gets.to_s
  pa=str.split
  stra=pa[0]
  strb=pa[1]
  ha[stra]=strb
end
#p ha

ha.each{|key,value|
  stt=key
  while ha[stt]!=nil
    stb=stt
    stt=ha[stt]
    ha.delete(stb)
  end
  hb[key]=stt
}
#p hb

hb.each{|key,value|
  puts"#{key} #{value}"#输出格式控制
}


n, m, k = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
total_sum = 0
for i in 1..n do
  this_sum = 0
  order = gets.split.map(&:to_i)
  order.each_with_index do |val, i|
    for j in 0..k do
      if val == arr[j]
        o = arr.delete_at(j)
        this_sum += j + 1
        arr.unshift(o)
      end
    end
  end
  total_sum += this_sum
end
puts total_sum

n, m, k = readline.split(' ').collect(&:to_i)
arr = readline.split(' ').collect(&:to_i)
sum = 0
n.times do
  items = readline.split(' ').collect(&:to_i)
  items.each do |item|
    sum += arr.index(item) + 1
    arr.delete item
    arr.insert(0, item)
  end
end
puts sum

io = lambda {gets.split.map(&:to_i)}
n, m, k = io.call
p = io.call
r = 0

(0...n).each do |i|
  a = io.call
  a.each do |j|
    d = p.index(j)
    p.unshift(p.delete_at(d))
    r += d + 1
  end
end

puts r


n = gets.to_i

vers = []
targets = []
n.times do |i|
    s = gets.split.map{|i| i.to_i}
    targets << s[0] + s[1]
    vers << s[0]
end

if n < 2 then
    puts "NO"
else
    c = 0
    n.times do |i|
        if (k = vers.index(targets[i])) then
            if targets[k] == vers[i] then
                c = 2
            end
        end
    end
    if c > 1 then
        puts "YES"
    else
        puts "NO"
    end
end

n=gets.to_i
data=[]
n.times{data.push(gets.split.map(&:to_i)) }
data.each do |i|
        data.each do |j|
                if i[0]+i[1]==j[0] && j[0]+j[1]==i[0] then
                        puts "YES"
                        exit
                end
        end
end
puts "NO"

n = gets.to_i

mas = Array.new()
for i in 0..n-1
  s = gets.split(" ")
  mas[i] = [s[0].to_i, s[1].to_i]
end

for i in 0..n-1
  for j in 0..n-1
    if (i != j && (mas[i][0] + mas[i][1] == mas[j][0]) && (mas[j][0] + mas[j][1] == mas[i][0]))
      puts "YES"
      exit
    end
  end
end

puts "NO"


t = gets.to_i
t.times do
  n, d = gets.split.map { |x| x.to_i }
  a = gets.split.map { |x| x.to_i }
  puts a.sort[0..1].sum <= d || a.max <= d ? "YES" : "NO"
end
#

gets.to_i.times do
  n,d=gets.split.map(&:to_i)
  a=gets.split.map(&:to_i).sort
  if a[-1]<=d
    puts "YES"
  elsif a[0]+a[1]<=d
    puts "YES"
  else
    puts "NO"
  end
end

gets.to_i.times do
  n, d = gets.split.map &:to_i
  a = gets.split.map &:to_i
  a.sort!
  if a[0] + a[1] <= d || a[-1] <= d
    puts "YES"
  else
    puts "NO"
  end
end

#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

T=gets.to_i
T.times do
    n,d=get_i
    a=get_i
    f=true
    n.times do|i|
      if a[i]>d
          f=false
          break
      end
    end
    if f
        puts "YES"
        next
    end
    is_find=false
    (n-1).times do|i|
        (i+1).upto(n-1) do|j|
          if a[i]+a[j]<=d
              is_find=true
              break
          end
        end
    end
    if is_find
        puts "YES"
    else
        puts "NO"
    end
end

def read
  gets.split.map &:to_i
end
gets.to_i.times do
  _, d = read
  a = read.sort!
  puts a[0] + a[1] <= d || a[-1] <= d ? "YES" :"NO"
end

t = gets.chomp.to_i
t.times do
  n, d = gets.chomp.split.map(&:to_i)
  arr = gets.chomp.split.map(&:to_i)
  arr = arr.sort
  puts arr[0] + arr[1] <= d || arr.all?{|el| el <= d} ? "YES" : "NO"
end

gets.to_i.times do
  n,d=gets.split.map(&:to_i)
  a=gets.split.map(&:to_i).sum
  if a<=d*n
    puts "YES"
  else
    puts "NO"
  end
end


n = gets.strip.to_i

arr = gets.strip.split(' ').map(&:to_i)

query = gets.strip.split(' ').map(&:to_i)

max = nil

pos = Hash.new()

arr.each_with_index do |a, i|
    pos[a] = i + 1
end

out = []
query.each do |q|
    if max.nil?
        max = pos[q]
        out << max
    else
        val = pos[q]
        if val > max
            out << (val - max)
            max = val
        else
            out << 0
        end
    end
end

puts out.join(' ')

# http://codeforces.com/contest/1073/problem/B

n = gets
array = gets.split(' ').map(&:to_i)
steps = gets.split(' ').map(&:to_i)

backpack = {}
result = []

steps.each do |step|
  if backpack[step]
    result << 0
  else
    count = 0
    begin
      num = array.shift
      count += 1
      backpack[num] = 1
    end while num != step

    result << count
  end
end

puts result.join(' ')


def compute(n, as)
  last = nil
  max = 0
  crt = 0

  as.each do |a|
    if last
      if last * 2 >= a
        crt += 1
      else
        crt = 1
      end
    else
      crt += 1
    end

    max = [crt, max].max
    last = a
  end

  max

end

def solution
  n = read_int
  as = read_ints

  puts compute(n, as)
end

def read_int
  gets.to_i
end

def read_ints
  gets.split.map(&:to_i)
end

def read_string
  gets.chomp
end

solution unless ENV['TEST__MODE']

n = gets.to_i
a = gets.split.map(&:to_i)
puts a.chunk_while { _1 * 2 >= _2 }.map(&:size).max

#! /usr/bin/ruby

gets
input = gets.chomp.split ' '
input.map! { |word| word.to_i  }

i = 0
j = 0
ans = 0

while j < input.size - 1
  if input[j + 1] <= 2 * input[j]
    j += 1
  else
    ans = [ans, j - i + 1].max
    j += 1
    i = j
  end
end

ans = [ans, j - i + 1].max

puts ans

N = gets.to_i
as = gets.split.map(&:to_i)
ans = 1
len = 1
now = as[0]
(1...N).each do |i|
    if now*2 >= as[i]
        now = as[i]
        len += 1
        ans = len if ans < len
    else
        len = 1
        now = as[i]
    end
end
puts ans

class Node
	attr_accessor :prev
	attr_accessor :next
	attr_accessor :data

	def initialize(p,n,d)
		@prev = p
		@next = n
		@data = d
	end
end

class Que
	def initialize()
		@front = nil
		@rear = nil
		@size = 0
	end

	def pushl(k)
		@size += 1
		a = Node.new(@rear,nil,k)
		if(@front == nil)
			@front = a
			@rear = a
		else
			@rear.next = a
			@rear = a
		end
	end

	def popf()
		@size -= 1
		rem = @front
		@front = @front.next
		# @front.prev = nil
		if (@size == 0)
			@rear = nil
		else
			@front.prev = nil
		end
		return rem.data
	end

	def contains(k)
		now = @front
		while(now != nil)
			if (now.data == k)
				return true
			else
				now = now.next
			end
		end
		return false
	end

	def pushf(k)
		@size += 1
		a = Node.new(nil,@front,k)
		@front = a
		if(@front == nil)
			@rear = a
		end
	end

	def popl()
		@size -= 1
		a = @rear
		if(@size == 0)
			@front = nil
			@rear = nil
		else
			@rear = @rear.prev
			@rear.next = nil
		end
		return a.data
	end
	def front()
		return @front.data
	end

	def size()
		return @size
	end

	def rear()
		return @rear.data
	end
end

useless = gets.chomp.to_i
inp = gets.chomp.split(" ")
arr = Array.new()
for i in inp
	arr << i.to_i
end
if useless == 1
	print(1)
	exit
end
q = Que.new()
q.pushl(arr[0])
max = -10
cur = 1
i = 1
marked = true
until i == useless
	if (marked)
		q.pushl(arr[i])
	end
	if(arr[i] <= q.front*2)
		cur += 1
		if(max < cur)
			max= cur
		end
		marked = true
	else
		q.popf
		if(q.size == 1)
			cur = 0
		end
		i -= 1
		marked = false
	end
	i += 1
end

print(max)

def binary_search(range)
  lower = 0
  upper = range.size
  while lower < upper
    mi = (lower + upper)/2
    yield(range[mi]) ? upper = mi : lower = mi + 1
  end
  [range[upper], upper]
end

n = gets.to_i
a = gets.split.map(&:to_i)
dp = Array.new(n)
e = Array.new(n)
dp[0] = 1
e[0] = 0
(1...n).each do |i|
  if 2*a[e[i-1]] >= a[i]
    e[i] = i
    dp[i] = dp[i-1]+1
  elsif 2*a[i-1] >= a[i]
    e[i] = i
    dp[i] = 2
  else
    e[i] = e[i-1]
    dp[i] = dp[i-1]
  end
end
puts dp.max

class Node
	attr_accessor :prev
	attr_accessor :next
	attr_accessor :data

	def initialize(p,n,d)
		@prev = p
		@next = n
		@data = d
	end
end

class Que
	def initialize()
		@front = nil
		@rear = nil
		@size = 0
	end

	def pushl(k)
		@size += 1
		a = Node.new(@rear,nil,k)
		if(@front == nil)
			@front = a
			@rear = a
		else
			@rear.next = a
			@rear = a
		end
	end

	def popf()
		@size -= 1
		rem = @front
		@front = @front.next
		# @front.prev = nil
		if (@size == 0)
			@rear = nil
		else
			@front.prev = nil
		end
		return rem.data
	end

	def contains(k)
		now = @front
		while(now != nil)
			if (now.data == k)
				return true
			else
				now = now.next
			end
		end
		return false
	end

	def pushf(k)
		@size += 1
		a = Node.new(nil,@front,k)
		@front = a
		if(@front == nil)
			@rear = a
		end
	end

	def popl()
		@size -= 1
		a = @rear
		if(@size == 0)
			@front = nil
			@rear = nil
		else
			@rear = @rear.prev
			@rear.next = nil
		end
		return a.data
	end
	def front()
		return @front.data
	end

	def size()
		return @size
	end

	def rear()
		return @rear.data
	end
end

useless = gets.chomp.to_i
inp = gets.chomp.split(" ")
arr = Array.new()
for i in inp
	arr << i.to_i
end
if useless == 1
	print(1)
	exit
end
q = Que.new()
q.pushl(arr[0])
max = -10
cur = 1
i = 1
marked = true
until i == useless
	if (marked)
		q.pushl(arr[i])
	end
	if(arr[i] <= q.front*2)
		cur += 1
		if(max < cur)
			max= cur
		end
		marked = true
	else
		q.popf
		cur -= 1
		i -= 1
		marked = false
	end
	i += 1
end

print(max)


# coding: utf-8

n = readline.to_i
arr = readline.chomp.split(' ').map(&:to_i)

sarr = arr.sort

if sarr == arr then
    puts 'yes'
    puts '1 1'
    STDOUT.flush
    exit! 0
end

l = ((0..arr.size-1).find_index {|i| arr[i] != sarr[i]}).to_i
r = ((0..arr.size-1).to_a.reverse.find {|i| arr[i] != sarr[i]}).to_i

parr = []
parr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size-1-r)

if parr == sarr then
    puts 'yes'
    puts "#{l+1} #{r+1}"
else
    puts 'no'
end

n = gets.to_i
a = gets.split.map(&:to_i)
b = a.sort
s = a.zip(b).index{|x, y| x != y} || 0
e = a.zip(b).rindex{|x, y| x != y} || 0
a[s..e] = a[s..e].reverse
if a == b
  puts 'yes', "#{s + 1} #{e + 1}"
else
  puts 'no'
end

n=gets.to_i
a=gets.split.map{|i| i.to_i}
b=a.clone.sort
if a==b
	puts "yes\n1 1"
	exit
end
l=0
n.times{|x| l=x; break if a[x]!=b[x]}
r=0
n.times{|x| r=n-1-x; break if a[n-x-1]!=b[n-x-1]}
if a[0,l]+a[l..r].reverse+a[r+1..-1] == b
	puts "yes\n#{l+1} #{r+1}"
elsif
	puts 'no'
end

n = gets.rstrip.to_i
arr = gets.rstrip.split(' ').map(&:to_i)

sorted_arr = arr.sort

l = r = 0
for i in 0..(n - 1)
  if arr[i] != sorted_arr[i]
    l = i
    break
  end
end

j = n - 1
while j >= 0 do
  if arr[j] != sorted_arr[j]
    r = j
    break
  end
  j -= 1
end

j = r
for i in l..r
  if arr[i] != sorted_arr[j]
    puts 'no'
    exit
  else
    j -= 1
  end
end

puts 'yes'
puts "#{l + 1} #{r + 1}"

n=gets.to_i
x=gets.split.map{|e| e.to_i}
c=""
arr=""
minP=0
maxP=0
(x.size-1).times{|i|
	s=""
	if x[i]<x[i+1] then
		s="+"
	else
		s="-"
	end
	if(s!=c) then
		arr<<s
		c=s
		if c=="-" then
			minP=i
		end
	end
	if c=="-" then
		maxP=i+1
	end
}

case arr
when "+",""
	puts "yes"
	puts "1 1"
when "-","+-","-+","+-+"
	ok=true
	if minP>0 then
		x1=x.slice(0..(minP-1))
		x2=x.slice(minP..maxP)
		if x1.max>x2.min then
			ok=false
		end
	end
	if maxP<(x.size-1) then
		x1=x.slice(minP..maxP)
		x2=x.slice(maxP+1,x.size)
		if x1.max>x2.min then
			ok=false
		end
	end
	if ok==false then
		puts "no"
	else
		puts "yes"
		puts [minP+1,maxP+1]*" "
	end
else
	puts "no"
end

n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
s = 0
e = 0
for i in 0..n-2
	if a[i]>a[i+1]
		s = i
		break
	end
end
(n-1).downto(1) do |i|
	if a[i]<a[i-1]
		e = i
		break
	end

end
	poss = true
for i in s..e-1
	if a[i] < a[i+1]
		poss = false
		break
	end
end

if (s == 0 or a[e] > a[s-1] ) && (e == n-1 or a[s]<a[e+1]) && poss
	poss = true
else
	poss = false
end

if poss
	puts "yes"
	puts "#{s+1} #{e+1}"
else
	puts "no"
end

# coding: utf-8

# if __FILE__ == $0
# end

n = gets.to_i
a = gets.split.map(&:to_i)
prev = -1
chp = []
a.each_with_index { |i, index|
    if i - prev < 0
        chp << index
    end

    prev = i
}
if chp.length == 0
    puts "yes"
    puts "1 1"
elsif chp.length != chp.last - (chp.first - 1)
    puts "no"
else
    fidx = chp.first - 1
    lidx = chp.last
    item_before_fidx = -1
    item_after_lidx = 10**9 + 1
    if fidx > 0
        item_before_fidx = a[fidx - 1]
    end

    if lidx < (n-1)
        item_after_lidx = a[lidx + 1]
    end

    if item_before_fidx <= a[lidx] && item_after_lidx >= a[fidx]
        puts "yes"
        puts "#{fidx+1} #{lidx+1}" # 1-based indices
    else
        puts "no"
    end
end

# if yes: print 'yes' and show begin/end index
# else no

n = gets.to_i
arr =gets.split(" ").map(&:to_i)
prev = arr[0]
seg = nil
seg_start = nil
seg_end = nil
ans = true
seg_found = false
(1..n-1).each do |i|
	if arr[i] >= prev
		if seg
			seg = nil
			seg_end = i - 1
		end
	else
		unless seg
			seg = true
			seg_found = true
			seg_start = i - 1
		end
	end
	prev = arr[i]
end
if seg_found
	seg_end = n - 1 if !seg_end && seg && seg_start
	# puts "#{seg_start} #{seg_end}"
	first_part = arr[0..seg_start - 1] unless seg_start == 0
	last_part = arr[seg_end+1..n-1]
	mid_part = arr[seg_start..seg_end].reverse if arr[seg_start..seg_end]
	new_arr =  (first_part || [] )+ (mid_part || []) +  (last_part ||  [])
	# puts "#{first_part} #{arr[seg_start..seg_end].reverse} #{arr[seg_end+1..n-1]}"
	ans = false unless  new_arr == arr.sort
else
	if arr == arr.sort
		seg_start = 0
		seg_end = 0
	else
		ans = false
	end
end

if ans
	puts "yes"
	puts "#{seg_start+1} #{seg_end+1}"
else
	puts "no"
end

def isSorted(a)
  a.inject([-1, true]) { |p, v|
    [v, (p[1] and p[0] <= v)]
  }[1]
end

n = gets.to_i
a = gets.split.map(&:to_i)
p1 = -1
p2 = -1

prev = -1
a.each_with_index { |val, idx|
  if p1 == -1
    if prev > val
      p1 = idx-1
    end
  else
    if prev < val
      p2 = idx-1
      break
    end
  end
  prev = val
}

if p1 == -1 and p2 == -1
  p1 = p2 = 0
elsif p2 == -1
  p2 = n-1
end
sorted = a[0...p1] + a[p1..p2].reverse + a[p2+1...n]

if isSorted sorted
  puts "yes"
  puts "#{p1+1} #{p2+1}"
else
  puts "no"
end

def find_point(a)
  p1 = -1
  p2 = -1
  prev = -1
  a.each_with_index do |val, idx|
    if p1 == -1
      if prev > val
        p1 = idx-1
      end
    else
      if prev < val
        p2 = idx-1
        break
      end
    end
    prev = val
  end
  [p1, p2]
end

n = gets.to_i
a = gets.split.map(&:to_i)
p1,p2 = find_point a
if p1 == -1 and p2 == -1
  p1 = p2 = 0
elsif p2 == -1
  p2 = n-1
end
sorted = a[0...p1] + a[p1..p2].reverse + a[p2+1...n]

if sorted == a.sort
  puts "yes"
  puts "#{p1+1} #{p2+1}"
else
  puts "no"
end

n = gets.to_i
a = gets.split.map(&:to_i)
b = a.sort
s = nil
e = nil
n.times do |i|
  s = i if a[i] != b[i] && s == nil
  e = i if a[i] != b[i]
end
s = e = 0 if s == nil || e == nil
aa = [a[0...s], a[s..e].reverse, a[e + 1..-1]]
if aa.join == b.join
  puts "yes"
  puts "#{s + 1} #{e + 1}"
else
  puts "no"
end

# coding: utf-8

n = readline.to_i
arr = readline.chomp.split(' ').map(&:to_i)

sarr = arr.sort

if sarr == arr then
    puts 'yes'
    puts '1 1'
else

    l = ((0..arr.size-1).find_index {|i| arr[i] != sarr[i]}).to_i
    r = ((0..arr.size-1).to_a.reverse.find {|i| arr[i] != sarr[i]}).to_i

    parr = []
    parr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size-1-r)

    if parr == sarr then
        puts 'yes'
        puts "#{l+1} #{r+1}"
    else
        puts 'no'
    end
end

length = gets.split.map{|_|_.to_i}
array = gets.split.map{|_|_.to_i}

sorted_array = array.sort
started = 0
ended = 0
switch = 0
index = 0

while index <= array.length
  if sorted_array[index] != array[index]
    if switch % 2 == 0
      started = index
      switch += 1
    else
      ended = index
    end
  end

  index += 1
end

if switch == 0 || sorted_array[started..ended] == array[started..ended].reverse
  puts "yes"
  puts [started + 1, ended + 1].join(" ")
else
  puts "no"
end

n = gets.chomp.to_i
list = gets.chomp.split.map(&:to_i)

sorted_list = list.sort
diff_pos = []

for i in 0..(n - 1)
  if list[i] != sorted_list[i]
    diff_pos << i
  end
end

if diff_pos.empty?
  l = 0
  r = 0
else
  l = diff_pos[0]
  r = diff_pos[-1]
end

reverse_segment = list[l..r].dup

for i in 0..((reverse_segment.length - 1)/ 2.0)
  temp = reverse_segment[i]
  reverse_segment[i] = reverse_segment[reverse_segment.length - 1 - i]
  reverse_segment[reverse_segment.length - 1 - i] = temp
end

list[l..r] = reverse_segment

if list == sorted_list
  puts "yes"
  print l + 1, " ", r + 1
else
  puts "no"
end

gets
a = gets.split(' ').map(&:to_i)

l = 0
r = a.size

a.unshift 0
a.push 10 ** 9 + 1

while l < r && a[l] < a[l+1]
  l += 1
end

while r > l && a[r] > a[r-1]
  r -= 1
end

if a[l] < a[r+1] && a[r] > a[l-1] && (l+1..r).all? { |i| a[i-1] > a[i] }
  puts "yes"
  puts "#{l} #{r}"
else
  puts "no"
end

n = gets.to_i
a = gets.chomp.split.map(&:to_i)
p = q = nil
(0...n - 1).each { |i|
  if a[i] > a[i + 1]
    if q
      puts 'no'
      exit
    end
    p = i unless p
  else
    q = i if p && !q
  end
}
p = n - 1 unless p
q = n - 1 if p && !q
puts (p == 0 || a[p - 1] < a[q]) && (q == n - 1 || a[p] < a[q + 1]) ? "yes\n#{[p + 1, q + 1].join(' ')}" : 'no'

def no;puts "no";exit;end
n=gets.to_i
a=gets.split.map{|s|s.to_i}
l = nil
r = nil
(n-1).times do |i|
  if r
    no if a[i] > a[i+1]
  elsif l
    r = i if a[i] < a[i+1]
  else
    l = i if a[i] > a[i+1]
  end
end
l || (l, r = 0, 0)
r ||= n-1
no if r < n-1 && a[l] > a[r+1]
no if l > 0 && a[l-1] > a[r]
puts "yes"
puts [l+1, r+1].join(" ")

n = gets.to_i
a = gets.split.map &:to_i

def sign n
  n == 0 ? 0 : n.abs / n
end
if a.length > 1
  segment_directions = []
  #negative descending, positive ascending
  direction = sign(a[1] - a[0])
  start_index = 0
  end_index = 1

  for i in 2 ... n
    local_direction = sign(a[i] - a[i - 1])
    if local_direction == direction
      end_index = i
    else
      segment_directions << [direction, start_index, end_index]
      direction = local_direction
      start_index = i - 1
      end_index = i
    end
  end
  segment_directions << [direction, start_index, end_index]

  descending_segments = segment_directions.select {|d| d[0] == -1}

  if descending_segments.length > 1
    puts "no"
  elsif descending_segments.length == 1
    reverse_start_index = descending_segments[0][1]
    reverse_end_index = descending_segments[0][2]
    seg_strt_gt_pre = reverse_start_index > 0? a[reverse_end_index] > a [reverse_start_index - 1] : true
    seg_end_lt_nxt = reverse_end_index < n - 1 ? a[reverse_start_index] < a[reverse_end_index + 1] : true;
    if seg_strt_gt_pre &&  seg_end_lt_nxt
      puts "yes"
      puts "#{reverse_start_index + 1} #{reverse_end_index + 1}"
    else
      puts "no"
    end
  else
    puts "yes"
    puts "1 1"
  end
else
  puts "yes", "1 1"
end

N = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)

rra = arr.sort

if rra == arr
  puts "yes\n1 1"
  exit
end

l = ((0...arr.size).find_index {|i| arr[i] != rra[i]}).to_i
r = ((0...arr.size).to_a.reverse.find {|i| arr[i] != rra[i]}).to_i

brr = []
brr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size - 1 - r)

if brr == rra
  puts 'yes'
  puts "#{l + 1} #{r + 1}"
else
  puts 'no'
end

n = gets.to_i
a = gets.split.map &:to_i
l = n
(1...n).each do |i|
  if a[i] < a[i - 1] then
    l = i
    break
  end
end
if l == n then
  puts 'yes'
  puts '1 1'
else
  r = n
  (l...n).each do |i|
    if a[i] > a[i - 1] then
      r = i
      break
    end
  end
  flag = true
  (0...(l-1)).each do |i|
    if a[i] > a[r - 1] then
      flag = false
      break
    end
  end
  if flag then
    (r...n).each do |i|
      if a[i] < a[i - 1] || a[i] < a[l-1] then
        flag = false
        break
      end
    end
  end
  if flag then
    puts 'yes'
    puts l.to_s + ' ' + r.to_s
  else
    puts 'no'
  end
end

n = gets.to_i;
arr = gets.chomp.split(' ').map(&:to_i);
sorted = arr.sort;

if (arr == sorted)
  puts "yes\n1 1";
  exit;
end

left  = (0...n).find_index  {|i| arr[i] != sorted[i]};
right = (0...n).to_a.rindex {|i| arr[i] != sorted[i]};

arr = arr.first(left) + arr[left..right].reverse + arr.last(n - right - 1);

if (arr == sorted)
  puts "yes\n#{left + 1} #{right + 1}\n";
else
  puts "no";
end

n=gets.to_i
a=gets.chomp.split.map(&:to_i).unshift(0)
a[n+1]=1000000001
i=1
while i<n
	break if a[i]>a[i+1]
	i+=1
end
if i==n
	puts "yes"
	puts "1 1"
else
	j=n
	while j>1
		break if a[j]<a[j-1]
		j-=1
	end
	k=i
	while k<j
		break if a[k]<a[k+1]
		k+=1
	end
	if k!=j||a[i]>a[j+1]||a[i-1]>a[j]
		puts "no"
	else
		puts"yes"
		puts "#{i} #{j}"
	end
end

N = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
rra = arr.sort

if rra == arr
  puts "yes\n1 1"
  exit
end

l = ((0...arr.size).find_index {|i| arr[i] != rra[i]}).to_i
r = ((0...arr.size).to_a.reverse.find {|i| arr[i] != rra[i]}).to_i

brr = []
brr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size - 1 - r)

if brr == rra
  puts "yes"
  puts "#{l + 1} #{r + 1}"
else
  puts "no"
end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1

    break if i == size
  end

  while numbers[j] == sorted_array[j]
    j -= 1

    break if j == -1
  end

  numbers[i..j] = numbers[i..j].reverse

  if numbers == sorted_array
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  else
    puts 'no'
  end
end

N = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)

rra = arr.sort

if rra == arr
  puts 'yes'
  puts '1 1'
  exit! 0
end

l = ((0...arr.size).find_index {|i| arr[i] != rra[i]}).to_i
r = ((0...arr.size).to_a.reverse.find {|i| arr[i] != rra[i]}).to_i

brr = []
brr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size - 1 - r)

if brr == rra
  puts 'yes'
  puts "#{l + 1} #{r + 1}"
else
  puts 'no'
end

N = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
rra = arr.sort

if rra == arr
  puts "yes\n1 1"
  exit
end

l = ((0...arr.size).find_index {|i| arr != rra[i]}).to_i
r = ((0...arr.size).to_a.reverse.find {|i| arr[i] != rra[i]}).to_i

brr = []
brr = arr.first(l) + arr[l..r].reverse + arr.last(arr.size - 1 - r)

if brr == rra
  puts "yes"
  puts "#{l + 1} #{r + 1}"
else
  puts "no"
end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  left_index = i
  right_index = j

  while left_index <= right_index
    break if numbers[i] != sorted_array[j]
    left_index +=1
    right_index -= 1
  end

  if left_index < right_index
    puts 'no'
  else
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  end

  # numbers[i..j] = numbers[i..j].reverse

  # if numbers == sorted_array
  #   puts 'yes'
  #   puts "#{i + 1} #{j + 1}"
  # else
  #   puts 'no'
  # end

end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  left_index = i
  right_index = j

  while left_index < right_index
    break if numbers[i] != numbers[j]
    left_index +=1
    right_index -= 1
  end

  if left_index < right_index
    puts 'no'
  else
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  end

  # numbers[i..j] = numbers[i..j].reverse

  # if numbers == sorted_array
  #   puts 'yes'
  #   puts "#{i + 1} #{j + 1}"
  # else
  #   puts 'no'
  # end

end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  left_index = i
  right_index = j

  not_sorted = false

  while left_index <= right_index
    if numbers[left_index] != sorted_array[right_index]
      not_sorted = true
      break
    end
    left_index +=1
    right_index -= 1
  end

  if not_sorted
    puts 'no'
  else
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  end

  # numbers[i..j] = numbers[i..j].reverse

  # if numbers == sorted_array
  #   puts 'yes'
  #   puts "#{i + 1} #{j + 1}"
  # else
  #   puts 'no'
  # end
end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  left_index = i
  right_index = j

  while left_index <= right_index
    break if numbers[i] != numbers[j]
    left_index +=1
    right_index -= 1
  end

  if left_index < right_index
    puts 'no'
  else
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  end

  # numbers[i..j] = numbers[i..j].reverse

  # if numbers == sorted_array
  #   puts 'yes'
  #   puts "#{i + 1} #{j + 1}"
  # else
  #   puts 'no'
  # end

end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if size == 1
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  numbers[i..j] = numbers[i..j].reverse

  puts numbers == sorted_array ? 'yes' : 'no'
end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if size == 1
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = 1
  while i < size - 1
    b = numbers.dup
    b[i..j] = b[i..j].reverse!
    if b == sorted_array
      puts 'yes'
      puts "#{i + 1} #{j + 1}"
      break
    end
    j += 1
    if j == size
      i += 1
      j = i + 1
    end
  end
  puts 'no' if i >= size - 1
end

size = gets.to_i

numbers = gets.split(' ').map(&:to_i)

sorted_array = numbers.sort

if numbers == sorted_array
  puts 'yes'
  puts '1 1'
else
  i = 0
  j = size - 1

  while numbers[i] == sorted_array[i]
    i += 1
  end

  while numbers[j] == sorted_array[j]
    j -= 1
  end

  left_index = i
  right_index = j

  while left_index <= right_index
    break if numbers[left_index] != sorted_array[right_index]
    left_index +=1
    right_index -= 1
  end

  if left_index <= right_index
    puts 'no'
  else
    puts 'yes'
    puts "#{i + 1} #{j + 1}"
  end

  # numbers[i..j] = numbers[i..j].reverse

  # if numbers == sorted_array
  #   puts 'yes'
  #   puts "#{i + 1} #{j + 1}"
  # else
  #   puts 'no'
  # end
end

n = gets.rstrip.to_i
arr = gets.rstrip.split(' ').map(&:to_i)

l = 0
arr.each_with_index do |v, i|
  if arr[i + 1] && arr[i] > arr[i + 1]
    l = i
    break
  end
end

r = l
while arr[l] >= arr[r] && r < arr.size - 1 do
  r += 1
end

r -= 1 if r != (arr.size - 1)
r -= 1 if arr[r] > arr[l]

sorted_arr = arr.sort
arr[l], arr[r] = arr[r], arr[l]

if sorted_arr == arr
  puts 'yes'
  puts "#{l + 1} #{r + 1}"
else
  puts 'no'
end

n = gets.rstrip.to_i
arr = gets.rstrip.split(' ').map(&:to_i)

l = 0
arr.each_with_index do |v, i|
  if arr[i + 1] && arr[i] > arr[i + 1]
    l = i
    break
  end
end

r = l
while arr[l] >= arr[r] && r < arr.size - 1 do
  r += 1
end

r -= 1 if r != (arr.size - 1)
r -= 1 if arr[r] > arr[l]

sorted_arr = arr.sort
arr[l], arr[r] = arr[r], arr[l]

if sorted_arr == arr
  puts 'yes'
  puts "#{arr[l]} #{arr[r]}"
else
  puts 'no'
end

n=gets.to_i
x=gets.split.map{|e| e.to_i}
c=""
arr=""
minP=0
maxP=0
(x.size-1).times{|i|
	s=""
	if x[i]<x[i+1] then
		s="+"
	else
		s="-"
	end
	if(s!=c) then
		arr<<s
		c=s
		if c=="-" then
			minP=i
		end
	end
	if c=="-" then
		maxP=i+1
	end
}

case arr
when "+"
	puts "yes"
	puts "1 1"
when "-","+-","-+","+-+"
	ok=true
	if minP>0 then
		x1=x.slice(0..(minP-1))
		x2=x.slice(minP..maxP)
		if x1.max>x2.min then
			ok=false
		end
	end
	if maxP<(x.size-1) then
		x1=x.slice(minP..maxP)
		x2=x.slice(maxP+1,x.size)
		if x1.max>x2.min then
			ok=false
		end
	end
	if ok==false then
		puts "no"
	else
		puts "yes"
		puts [minP+1,maxP+1]*" "
	end
else
	puts "no"
end

n, k = gets.split.map{|_|_.to_i}
a = gets.split.map{|_|_.to_i}

length = gets.split.map{|_|_.to_i}
array = gets.split.map{|_|_.to_i}

sorted_array = array.sort
started = -1
ended = -1
switch = 0
index = 0

while index <= array.length
  if sorted_array[index] != array[index]
    if switch % 2 == 0
      started = index
      switch += 1
    else
      ended = index
    end
  end

  index += 1
end

if switch == 0 || sorted_array[started..ended] == array[started..ended].reverse
  puts "yes"
  puts [started + 1, ended + 1].join(" ")
else
  puts "no"
end

length = gets.split.map{|_|_.to_i}
array = gets.split.map{|_|_.to_i}

sorted_array = array.sort
started = -1
ended = -1
switch = 0
index = 0

while index <= array.length
  if sorted_array[index] != array[index]
    if switch % 2 == 0
      started = index
      switch += 1
    else
      ended = index
    end
  end

  index += 1
end

if sorted_array[started..ended] == array[started..ended].reverse
  puts "yes"
  puts [started + 1, ended + 1].join(" ")
else
  puts "no"
end

n = gets.chomp.to_i
list = gets.chomp.split.map(&:to_i)

sorted_list = list.sort

if sorted_list == list
  puts "yes"
  print 1, " ", n
else
  diff_pos = []

  for i in 0..(n - 1)
    if list[i] != sorted_list[i]
      diff_pos << i
    end
  end

  l = diff_pos[0]
  r = diff_pos[-1]

  reverse_segment = list[l..r].dup

  for i in 0..((reverse_segment.length - 1)/ 2.0)
    temp = reverse_segment[i]
    reverse_segment[i] = reverse_segment[reverse_segment.length - 1 - i]
    reverse_segment[reverse_segment.length - 1 - i] = temp
  end

  list[l..r] = reverse_segment

  if list == sorted_list
    puts "yes"
    print l + 1, " ", r + 1
  else
    puts "no"
  end
end

n = gets.chomp.to_i
list = gets.chomp.split.map(&:to_i)

temp_list = list.dup
result = []

for r in 0..(n - 1)
  for l in 0..r
    temp = list[r]
    list[r] = list[l]
    list[l] = temp
    if list == list.sort
      break result = [l + 1, r + 1]
    end
  end

  list = temp_list
end

if result.empty?
  puts "no"
else
  puts "yes"
  print result[0], " ", result[1]
end


gets
a = gets.strip.split(' ').map(&:to_i)

if a.select { |i| i.zero? }.size.zero?
  puts "-1"
  exit
end

sum = 0
count = 0
mx = 0
a.each { |e|
  if e == 5
    sum += 5
    count += 1
  end
  if sum % 9 == 0
    mx = count
  end
}

if mx.zero?
  puts "0"
  exit
end
mx.times { print '5' }
(a.size - count).times { print '0' }
puts ""

n=gets.to_i
x=gets.split.map{|e| e.to_i}
if x.index(0) then
	y=x.count{|e|
		e==5
	}
	z=x.size-y
	while (y*50)%90!=0
		y-=1
	end

	if y==0 then
		puts 0
	else

		y.times{
			print 5
		}
		z.times{
			print 0
		}
		puts ""
	end
else
	puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

if a_five >= 9 && a_zero >= 1
  puts "5" * (a_five / 9 * 9) + "0" * a_zero
elsif a_zero >= 1
    puts 0
else
    puts -1
end

cnt=[0]*6
a = $<.to_a[1].split.map(&:to_i)
a.each do |x|
  cnt[x] += 1
end
if cnt[5] >= 9 and cnt[0] > 0
  puts '5' * (cnt[5] - cnt[5] % 9) + '0' * cnt[0]
elsif cnt[0] > 0
  puts '0'
else
  puts '-1'
end

c=Array.new(6,0)
gets
gets.split.map(&:to_i).each{|i|c[i]+=1}
a,b=c[0],c[5]-c[5]%9
if a == 0
	p (-1)
elsif b == 0
	p 0
else
	puts "5"*b+"0"*a
end

n,res0,res5 = gets.chomp.to_i, 0, 0
a = gets.chomp.split.map(&:to_i)
a.each { |x| if x==5; res5+=1 else res0+=1 end }
if res0>0; puts '5'*(res5/9*9)+'0'*(res5>8?res0:1) else puts '-1' end

n = gets.to_i
a = gets.split(' ').map{|e| e.to_i}
c = Hash.new(0)
a.each{|e|
    c[e] += 1;
}

if c[5]/9 > 0 and c[0] > 0 then
    (c[5]/9 * 9).times{ print 5 }
    c[0].times{print 0}
elsif c[0] > 0
    print 0
else
    print -1
end
puts

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
res0, res5 = 0, 0
a.each { |x| if x==5; res5+=1 else res0+=1 end }
if res0>0
  puts '5'*(res5/9*9)+'0'*(res5>8?res0:1)
else
  puts '-1'
end

cnt = gets.to_i
cards = gets.split
n0 = n5 = 0
cards.each {|c|
	if c == "0"
		n0 += 1
	else
		n5 += 1
	end
}
if n0 == 0
	print -1
elsif n5 < 9
	print 0
else
	print "5" * ((n5/9)*9) + "0" * n0
end

#! /usr/bin/env ruby

n = STDIN.gets.to_i
numbers = STDIN.gets.to_s.split(' ').map(&:to_i)

if numbers.length != n
  raise ArgumentError.new
end

def check(numbers, n)
  if numbers.none?(&:zero?)
    return nil
  end
  numbers.sort!.reverse!

  while numbers.first == 5
    sum = numbers.count{|i| i == 5} * 5
    if sum % 9 == 0
      return numbers.join.to_i
    end
    numbers.shift
  end

  0
end

answer = check(numbers, n)
if answer.nil?
  puts "-1"
else
  puts answer
end

f=gets.chomp.to_i
z=gets.chomp.split(" ").count('0')
f=f-z
if z==0 ||(f<9 && z==0)
puts "-1"
elsif f<9 && z>0
puts "0"
else
p="555555555"*(f/9)+("0"*z)
puts p
end

n = gets.to_i
a = gets.split.map { |x| x.to_i }

c0 = a.count 0
c5 = a.count 5

if c0 == 0
	puts -1
elsif c5 < 9
	puts 0
else
	puts '5' * (c5 / 9 * 9) + '0' * c0
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
res0, res5 = 0, 0
a.each { |x| if x==5; res5+=1 else res0+=1 end }
puts '5'*(res5/3*3)+'0'*(res5>2?res0:1)

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
res0, res5 = 0, 0
a.each { |x| if x==5; res5+=1 else res0+=1 end }
if res0>0
  puts '5'*(res5/3*3)+'0'*(res5>2?res0:1)
else
  puts '-1'
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
res0, res5 = 0, 0
a.each { |x| if x==5; res5+=1 else res0+=1 end }
puts '5'*(res5/5*5)+'0'*res0

cnt = gets.to_i
cards = gets.split
n0 = n5 = 0
cards.each {|c|
	if c == "0"
		n0 += 1
	else
		n5 += 1
	end
}
if n0 == 0
	print -1
elsif n5 < 9
	print 0
else
	print "9" * ((n5/9)*9) + "0" * n0
end

gets
a = gets.strip.split(' ').map(&:to_i)

if a.select { |i| i.zero? }.size.zero?
  puts "-1"
  exit
end

sum = 0
count = 0
mx = 0
a.each { |e|
  if e == 5
    sum += 5
    count += 1
  end
  if sum % 9 == 0
    mx = count
  end
}

mx.times { print '5' }
(a.size - count).times { print '0' }
puts ""

gets
a = gets.strip.split(' ').map(&:to_i)

if a.select { |i| i.zero? }.size.zero?
  puts "-1"
  exit
end

sum = 0
count = 0
mx = 0
a.each { |e|
  if e == 5
    sum += 5
    count += 1
  end
  if sum % 9 == 0
    mx = count
  end
}

mx.times { print '5' }
puts '0'

gets
a = gets.strip.split(' ').map(&:to_i)

if a.select { |i| i.zero? }.size.zero?
  puts "-1"
  exit
end

if a.select { |i| i.zero? }.size == 0
  puts "0"
  exit
end

sum = 0
count = 0
mx = 0
a.each { |e|
  if e == 5
    sum += 5
    count += 1
  end
  if sum % 9 == 0
    mx = count
  end
}

mx.times { print '5' }
(a.size - count).times { print '0' }
puts ""

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

s = ""
divideds = []
(0..1000).each do |i|
  s_zero = (s + "0")
  s_five = (s + "5")
  if s_zero.to_i % 90 == 0 and
     s_zero.count("0") <= a_zero and
     s_zero.count("5") <= a_five then
    divideds << s_zero
  end
  if s_five.to_i % 90 == 0 and
     s_five.count("0") <= a_zero and
     s_five.count("5") <= a_five then
    divideds << s_five
  end
  s += "5"
end

ans = divideds.sort[-1]
puts ans ? ans : -1

n = gets.chomp.to_i
a = gets.chomp.split

a_five = a.count "5"
a_zero = a.count "0"

s = ""
divideds = []
(0...a_five).each do |i|
  if (s+"0").to_i % 90 == 0
    divideds << (s+"0").to_i
  end
  if (s+"5").to_i % 90 == 0
    divideds << (s+"5").to_i
  end
  s += "5"
end

ans = divideds.reject{|i| i % 90 != 0}.sort[-1]
if ans
  puts ans
else
  puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

if a_five >= 9 and a_zero >= 1
  puts "5" * a_five + "0" * a_zero
elsif a_zero >= 1
  puts 0
else
  puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

s = ""
divideds = []
(0...1000).each do |i|
  s_zero = (s + "0")
  s_five = (s + "5")
  if s_zero.to_i % 90 == 0 and
     s_zero.count("0") <= a_zero and
     s_zero.count("5") <= a_five then
    divideds << s_zero
  end
  if s_five.to_i % 90 == 0 and
     s_five.count("0") <= a_zero and
     s_five.count("5") <= a_five then
    divideds << s_five
  end
  s += "5"
end

ans = divideds.sort[-1]
puts ans ? ans : -1

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

if a_five >= 9 and a_zero >= 1
  puts ("5" * a_five + "0" * a_zero).gsub("000000000","555555555")
elsif a_zero >= 1
  puts 0
else
  puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_five = a.count "5"
a_zero = a.count "0"

s = ""
divideds = []
(0...a_five).each do |i|
  if (s+"0").to_f % 90 == 0
    divideds << (s+"0").to_i
  end
  if (s+"5").to_f % 90 == 0
    divideds << (s+"5").to_i
  end
  s += "5"
end

ans = divideds.reject{|i| i % 90 != 0}.sort[-1]
if ans
  puts ans
else
  puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

if a_five >= 9
  puts "5" * (a_five / 9 * 9) + "0" * a_zero
elsif a_zero >= 1
    puts 0
else
    puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

if a_five >= 9
  puts "5" * (a_five / 9) + "0" * a_zero
elsif a_zero >= 1
    puts 0
else
    puts -1
end

n = gets.chomp.to_i
a = gets.chomp.split

a_zero = a.count "0"
a_five = a.count "5"

s = ""
divideds = []
(0...a_five).each do |i|
  s_zero = (s + "0")
  s_five = (s + "5")
  if s_zero.to_i % 90 == 0 and
     s_zero.count("0") <= a_zero and
     s_five.count("5") <= a_five then
    divideds << s_zero
  end
  if s_five.to_i % 90 == 0 and
     s_zero.count("0") <= a_zero and
     s_five.count("5") <= a_five then
    divideds << s_five
  end
  s += "5"
end

ans = divideds.sort[-1]
if ans
  puts ans
else
  puts -1
end

cnt=[0]*6
a = $<.to_a[1].split.map(&:to_i)
a.each do |x|
  cnt[x] += 1
end
if cnt[5] >= 9
  puts '5' * (cnt[5] - cnt[5] % 9) + '0' * cnt[0]
elsif cnt[0] > 0
  puts '0'
else
  puts '-1'
end

cnt=[0]*6
a = $<.to_a[1].split.map(&:to_i)
a.each do |x|
  cnt[x] += 1
end
if cnt[5] >= 9
  puts '5' * (cnt[5] - cnt[5] % 9) + '0' * cnt[0]
elsif cnt[0]
  puts '0'
else
  puts '-1'
end

n = gets.to_i
a = gets.split(' ').map{|e| e.to_i}
c = Hash.new(0)
a.each{|e|
    c[e] += 1;
}

if c[5]/9 > 0 and c[0] > 0 then
    c[5]/9.times{
        print 5
    }
    puts 0
else
    puts 0
end

n = gets.to_i
a = gets.split(' ').map{|e| e.to_i}
c = Hash.new(0)
a.each{|e|
    c[e] += 1;
}

if c[5]/9 > 0 and c[0] > 0 then
    c[5]/9.times{
        print 5
    }
    puts 0
else
    puts -1
end

n = gets.to_i
a = gets.split(' ').map{|e| e.to_i}
c = Hash.new(0)
a.each{|e|
    c[e] += 1;
}

if c[5]/9 > 0 and c[0] > 0 then
    c[5]/9.times{
        print 5
    }
    puts 0
elsif c[0] > 0
    puts 0
else
    puts -1
end

n = gets.to_i
a = gets.split.map { |x| x.to_i }

c0 = a.count 0
c5 = a.count 5

if c0 == 0 and c5 < 9
	puts -1
elsif c5 < 9
	puts 0
else
	puts '5' * (c5 / 9 * 9) + '0' * c0
end


at_exit do
  vertex_count, edge_count = get_numbers_from_line[0..1]
  linked_count = [0]*vertex_count
  edge_count.times do
    x,y = get_numbers_from_line[0..1]
    linked_count[x-1] += 1
    linked_count[y-1] += 1
  end

  counts = {}
  linked_count.each do |count|
    counts[count] ||= 0
    counts[count] += 1
  end
  one_count = counts[1] || 0
  two_count = counts[2] || 0

  if one_count == 2 && two_count == vertex_count - 2 && edge_count == vertex_count-1
    puts 'bus topology'
  elsif one_count == 0 && two_count == vertex_count && edge_count == vertex_count
    puts 'ring topology'
  elsif one_count == vertex_count-1 && counts[vertex_count-1] == 1 && edge_count == vertex_count - 1
    puts 'star topology'
  else
    puts 'unknown topology'
  end

end

def get_numbers_from_line
  gets.strip.split.map(&:to_i)
end

class List
  attr_accessor :element, :next_elem

  def initialize(element, next_elem)
    @element = element
    @next_elem = next_elem
  end
end

class Graph
  attr_accessor :vertices

  def initialize(vertices)
    @vertices = vertices
  end

  def add_edge(number1, number2)
    if vertices[number1].nil? then
      vertices[number1] = List.new(number2, nil)
    else
      vertices[number1] = List.new(number2, vertices[number1])
    end
  end

  def print_edges
    vertices.each_with_index do |vertex, index|
      # next if vertex == ""
      while !vertex.nil? do
        puts "edge #{index} - #{vertex.element}"
        vertex = vertex.next_elem
      end
    end
  end

end

network = Graph.new([])
n, m = gets.strip.split(" ").map(&:to_i)
number_of_connected_vertices = Array.new(n, 0)
m.times do
  vertex1, vertex2 = gets.strip.split(" ").map{|num| num.to_i - 1}
  network.add_edge(vertex1, vertex2)
  network.add_edge(vertex2, vertex1)
  number_of_connected_vertices[vertex2] += 1
  number_of_connected_vertices[vertex1] += 1
end
results = number_of_connected_vertices.group_by{|i| i}
if results[n - 1] && results[n - 1].count == 1 &&
   results[1] && results[1].count == n - 1
   answer = 'star topology'
elsif results[1] && results[1].count == 2 &&
  results[2] && results[2].count == n - 2
  answer = 'bus topology'
elsif results[2] &&  results[2].count == n
  answer = 'ring topology'
else
  answer = 'unknown topology'
end
puts answer

n, m = gets.split.map(&:to_i)

edges = m.times.map{ gets.split.map(&:to_i) }
v = n.times.map{ 0 }

if m == n
  edges.each do |e|
    v[e[0] - 1] += 1
    v[e[1] - 1] += 1
    if v[e[1] - 1] > 2 || v[e[0] - 1] >2
      puts 'unknown topology'
      exit
    end
  end
  puts 'ring topology'
  exit
elsif m + 1 == n
  edges.each do |e|
    v[e[0] - 1] += 1
    v[e[1] - 1] += 1
  end
  v.sort!
  if v[0] == 1 && v[1] == 1 && v[2] == 2
    puts 'bus topology'
    exit
  elsif v[-1] == m
    puts 'star topology'
    exit
  end
end

puts 'unknown topology'

begin
  input = gets.chomp.split(" ")
  n = input[0].to_i
  m = input[1].to_i

  v1s = []
  v2s = []

  count_arr = []

  edges = []

  twos = 0
  nontwos = 0

  m.times do |i|
    input = gets.chomp.split(" ")

    v1 = input[0].to_i
    v2 = input[1].to_i

    v1s << v1
    v2s << v2

    count_arr[v1] ||= 0
    count_arr[v2] ||= 0

    count_arr[v1] += 1
    count_arr[v2] += 1

    if count_arr[v1] == m || count_arr[v2] == m
      puts "star topology"
      abort
    end
    edges << i
  end

  count_arr.compact!

  count_arr.each do |el|
    if el == 2
      twos += 1
    else
      if el > 2
        puts "unknown topology"
        abort
      else
        nontwos += 1
      end
    end
  end

  if (twos == count_arr.size - 2) && (nontwos == 2)
    puts "bus topology"
    abort
  end

  if n == m
    puts "ring topology"
    abort
  end

  puts "unknown topology"
rescue Exception
end


T = gets.to_i
T.times do
  n,s,t = gets.split.map(&:to_i)
  a = s+t-n
  t = [s-a,t-a].sort
  p t[1]+1
end

gets.to_i.times {
  n, s, t = gets.split.map &:to_i
  p [n - s + 1, n - t + 1].max
}

T = gets.to_i
T.times do
	n, s, t = gets.split.map(&:to_i)
	s, t = t, s if s < t
	if s + t <= n
		puts s + 1
	elsif
		cross = s + t - n
		puts s + 1 - cross
	end
end

T = gets.to_i
T.times do
  n,s,t = gets.split.map(&:to_i)
  a = s+t-n
  t = [a,s-a,t-a].sort
  ans = t[0]+t[1]+1
  p [ans,n].min
end


name,taxi,girls,pizza,maxt,maxp,maxg=[],[],[],[],0,0,0
n=gets.to_i
n.times do |i|
	taxi[i],pizza[i],girls[i]=0,0,0
	t,name[i]=gets.chomp.split
	t=t.to_i
	t.times do |j|
		str=gets.chomp.delete('-').split('')
		if str.uniq.count==1
			taxi[i]+=1
		elsif str[0]>str[1] && str[1]>str[2] && str[2]>str[3] && str[3]>str[4] && str[4]>str[5]
			pizza[i]+=1
		else
			girls[i]+=1
		end
	end
end
maxt,maxg,maxp=taxi.max,girls.max,pizza.max
print "If you want to call a taxi, you should call: "
post=0
for i in 0...n
	if maxt==taxi[i]
		post+=1
		print (post==1) ? name[i] : ", #{name[i]}"
	end
end
puts "."
print "If you want to order a pizza, you should call: "
post=0
for i in 0...n
	if maxp==pizza[i]
		post+=1
		print (post==1) ? name[i] : ", #{name[i]}"
	end
end
puts "."
print "If you want to go to a cafe with a wonderful girl, you should call: "
post=0
for i in 0...n
	if maxg==girls[i]
		post+=1
		print (post==1) ? name[i] : ", #{name[i]}"
	end
end
puts "."

n = gets.to_i
a = []
Array.new(n) do
    m, w = gets.split
    b = [0, 0, 0, w]
    m.to_i.times do
        s = gets.gsub(/\D/, '')
        if s =~ /^(.)\1*$/
            b[0] += 1
        elsif s.chars.to_a.sort.uniq * '' == s.reverse
            b[1] += 1
        else
            b[2] += 1
        end
    end
    a << b
end
b = ['call a taxi', 'order a pizza', 'go to a cafe with a wonderful girl']

3.times do |i|
    c = a.map{|_| _[i]}.max
    d = a.select{|_| _[i] == c}.map{|_| _[3]}
    puts "If you want to #{b[i]}, you should call: #{d * ', '}."
end

n=gets.to_i
shop=[]
taxi=[]
max=[0,0,0]
10.times{|k|
        taxi.push(k.to_s*6)
}
n.times{
        res=[0,0,0]
        k,name=gets.split
        k.to_i.times{
                a1,a2,a3=gets.split[0].split('-')
                t=a1+a2+a3
                if taxi.include?(t)
                        res[0]+=1
                else
                        v=Array.new(6){0}
                        6.times{|i| v[i]=t[i].to_i }
                        ok=true
                        5.times{|i|
                                ok=false if v[i]<=v[i+1]
                        }
                        if ok
                                res[1]+=1
                        else
                                res[2]+=1
                        end
                end
        }
        3.times{|i|
                max[i]=[max[i],res[i]].max
        }
        shop.push([name,res])
}
output=["If you want to call a taxi, you should call: ", "If you want to order a pizza, you should call: ","If you want to go to a cafe with a wonderful girl, you should call: "]
3.times{|k|
        print output[k]
        start=true
        shop.each{|t|
                if (t[1][k]==max[k]) then
                        print ", " unless start
                        start=false
                        print t[0]
                end
        }
        puts "."
}

#! /usr/bin/env ruby

t = gets.chomp.to_i
d = {}
name_list = []
(1..t).each do |x|
  n, name = gets.chomp.split
  n = n.to_i
  d[name] = {}
  name_list << name
  d[name]['taxi'] = 0
  d[name]['pizza'] = 0
  d[name]['girl'] = 0
  (1..n).each do |y|
    num = gets.chomp.split("-")
    if num.uniq.size == 1 and num.uniq.first.split(//).uniq.size == 1
      d[name]['taxi'] = (d[name]['taxi'] || 0) + 1
    elsif num.join.split(//).map(&:to_i) == num.join.split(//).map(&:to_i).sort.reverse.uniq
      d[name]['pizza'] = (d[name]['pizza'] || 0) + 1
    else
      d[name]['girl'] = (d[name]['girl'] || 0) + 1
    end
  end
end
max_taxi = d.keys.map { |i| [d[i]['taxi'] || 0, i] }.sort.max.first
max_pizza = d.keys.map { |i| [d[i]['pizza'] || 0, i] }.sort.max.first
max_girl = d.keys.map { |i| [d[i]['girl'] || 0, i] }.sort.max.first
taxi = name_list.select {|i| d[i]['taxi'] == max_taxi }.join(", ") + "."
pizza = name_list.select {|i| d[i]['pizza'] == max_pizza }.join(", ") + "."
girl = name_list.select {|i| d[i]['girl'] == max_girl }.join(", ") + "."
print ("If you want to call a taxi, you should call: " + taxi +"\n").to_s
print ("If you want to order a pizza, you should call: " + pizza +"\n").to_s
print ("If you want to go to a cafe with a wonderful girl, you should call: " + girl +"\n").to_s

#! /usr/bin/env ruby

def type_of_phone_number(number)
  return :taxi if number.uniq.size.equal? 1
  return :pizza if number.each_cons(2).all? {|x, y| x > y}
  return :girl
end

d = {}
k = [:taxi, :pizza, :girl]
k.each {|x| d[x] = [0, []]}

gets.to_i.times do |x|
  n, name = gets.chomp.split
  numbers = n.to_i.times.map {type_of_phone_number(gets.scan(/[0-9]/).map(&:to_i))}
  k.each do |x|
    if numbers.count(x) > d[x].first
      d[x] = [numbers.count(x), [name]]
    elsif numbers.count(x) == d[x].first
      d[x].last << name
    end
  end
end

puts "If you want to call a taxi, you should call: %s." %(d[:taxi][1] * ", ")
puts "If you want to order a pizza, you should call: %s." %(d[:pizza][1] * ", ")
puts "If you want to go to a cafe with a wonderful girl, you should call: %s." %(d[:girl][1] * ", ")

#! /usr/bin/env ruby

t = gets.chomp.to_i
d = {}
name_list = []
(1..t).each do |x|
  n, name = gets.chomp.split
  n = n.to_i
  d[name] = {}
  name_list << name
  d[name]['taxi'], d[name]['pizza'], d[name]['girl'] = 0, 0, 0
  (1..n).each do |y|
    num = gets.chomp.split("-")
    if num.uniq.size == 1 and num.uniq.first.split(//).uniq.size == 1
      d[name]['taxi'] = d[name]['taxi'] + 1
    elsif num.join.split(//).map(&:to_i) == num.join.split(//).map(&:to_i).sort.reverse.uniq
      d[name]['pizza'] = d[name]['pizza'] + 1
    else
      d[name]['girl'] = d[name]['girl'] + 1
    end
  end
end

max_taxi = d.keys.map { |i| [d[i]['taxi'], i] }.sort.max.first
max_pizza = d.keys.map { |i| [d[i]['pizza'], i] }.sort.max.first
max_girl = d.keys.map { |i| [d[i]['girl'], i] }.sort.max.first

taxi = name_list.select {|i| d[i]['taxi'] == max_taxi }.join(", ") + "."
pizza = name_list.select {|i| d[i]['pizza'] == max_pizza }.join(", ") + "."
girl = name_list.select {|i| d[i]['girl'] == max_girl }.join(", ") + "."

print ("If you want to call a taxi, you should call: " + taxi +"\n").to_s
print ("If you want to order a pizza, you should call: " + pizza +"\n").to_s
print ("If you want to go to a cafe with a wonderful girl, you should call: " + girl +"\n").to_s

require 'set'

def is_taxi(s)
  tmp = s.split("").select{|c| c != '-'}
  set = Set.new tmp
  set.length == 1
end

def is_pizza(s)
  flag = true
  tmp = nil
  s.split("").each do |c|
    if c != '-'
      if tmp == nil
        tmp = c.to_i
      else
        if tmp <= c.to_i
          flag = false
          break
        else
          tmp = c.to_i
        end
      end
    end
  end
  flag
end

def max_names(hash)
  max = hash.values.max
  names = hash.select{ |k, v|
    v == max
  }
  names.keys.join ', '
end

n = gets.chomp.to_i

taxi = {}
pizza = {}
girl = {}

n.times do
  tmp = gets.chomp.split " "
  s = tmp[0].to_i
  name = tmp[1]

  taxi[name] = 0
  pizza[name] = 0
  girl[name] = 0

  s.times do
    tmp2 = gets.chomp
    if is_taxi(tmp2)
      taxi[name] += 1
    elsif is_pizza(tmp2)
      pizza[name] += 1
    else
      girl[name] += 1
    end
  end
end

puts "If you want to call a taxi, you should call: " + max_names(taxi) + "."
puts "If you want to order a pizza, you should call: " + max_names(pizza) + "."
puts "If you want to go to a cafe with a wonderful girl, you should call: " + max_names(girl) + "."

def pizza?(num)
  num = num.gsub(/-/,'').chars.map(&:to_i)
  prev = 10
  num.each do |n|
    if prev > n
      prev = n
    else
      return false
    end
  end
  true
end

def taxi?(num)
  a = num[0]
  num.gsub(/[#{a}\-]/,'').size.zero?
end

def girl?(num)
  !taxi?(num) && !pizza?(num)
end

def which(num)
  return :taxi if taxi?(num)
  return :pizza if pizza?(num)
  return :girl
end

dics = {}
n = STDIN.gets.chomp.to_i
n.times do
  i, name = STDIN.gets.chomp.split(/ /)
  i = i.to_i
  dics[name] = {taxi: 0, pizza: 0, girl: 0}

  i.times do
    num = STDIN.gets.chomp
    dics[name][which(num)] += 1
  end
end

{taxi: "If you want to call a taxi, you should call: ",
 pizza: "If you want to order a pizza, you should call: ",
 girl: "If you want to go to a cafe with a wonderful girl, you should call: "}.each do |type, head|
  max = dics.map{|k,v| v[type] }.max
  puts head+dics.select{|k,v| v[type] == max }.keys.join(", ")+"."
end

n = gets.to_i
pb = []
n.times do |i|
  a  = [i]
  c,nm = gets.split
  a << nm
  h = Hash.new(0)
  c.to_i.times do
    pn = gets.strip.gsub(/-/,"").split(//)
    pn.uniq.sort.reverse
    if pn.uniq.size == 1
      h[:t] += 1
    elsif pn.uniq.sort.reverse == pn
      h[:p] += 1
    else
      h[:g] += 1
    end
  end
  a << h
  pb << a
end

mx = pb.map{|a| a[2][:t]}.max
tx = pb.select{|a| a[2][:t] == mx }

mx = pb.map{|a| a[2][:p]}.max
pz = pb.select{|a| a[2][:p] == mx }

mx = pb.map{|a| a[2][:g]}.max
gf = pb.select{|a| a[2][:g] == mx }

puts "If you want to call a taxi, you should call: #{tx.map{|a| a[1]}.join(", ")}."
puts "If you want to order a pizza, you should call: #{pz.map{|a| a[1]}.join(", ")}."
puts "If you want to go to a cafe with a wonderful girl, you should call: #{gf.map{|a| a[1]}.join(", ")}."

#!/usr/bin/ruby
class Number
  def initialize
  @mas=Array.new(6)
  end
  def mas
    @mas
  end
  def mas=(mas)
    @mas=mas
  end
  def isPizza()
    return @mas==@mas.uniq() && @mas==@mas.sort{|a,b| b<=>a}
  end
  def isTaxi()
     return @mas.uniq().size()==1
  end
end
class Person
  def initialize
  @name=String.new
  @taxiElements=0
  @girlElements=0
  @pizzaElements=0
  @numberArray=[]
  end
  def taxiElements
    @taxiElements
  end
  def pizzaElements
    @pizzaElements
  end
  def girlElements
    @girlElements
  end
  def name
    @name
  end
  def name=(name)
    @name=name
  end
  def numberArray
    @numberArray
  end
  def numberArray=(numberArray)
    @numberArray=numberArray
  end
  def countElements()
    for i in 0..(@numberArray.size()-1)
      element=@numberArray[i]
     if element.isTaxi()
    @taxiElements=@taxiElements+1
     elsif (element.isPizza())
    @pizzaElements=@pizzaElements+1
     else
    @girlElements=@girlElements+1
      end
    end
  end
end

require 'scanf'
count=(scanf("%d\n"))[0]
array=Array.new(count)
for i in 0..(count-1)
  array[i]=Person.new
  temp=scanf("%d %s\n")
  elements=temp[0]
  array[i].name=temp[1]
  array[i].numberArray=Array.new(elements)
  for j in 0..(elements-1)
    array[i].numberArray[j]=Number.new
    array[i].numberArray[j].mas=scanf("%c%c-%c%c-%c%c\n")
  end

end

array.each do |i|
  i.countElements()
end
maxPizza=(array.map{|x|x.pizzaElements}).max
maxTaxi=(array.map{|x|x.taxiElements}).max
maxGirl=(array.map{|x|x.girlElements}).max
outTaxi="If you want to call a taxi, you should call: "
outPizza="If you want to order a pizza, you should call: "
outGirl="If you want to go to a cafe with a wonderful girl, you should call: "
wasTaxi=false
wasPizza=false
wasGirl=false
array.each do |i|
  if i.taxiElements==maxTaxi
    if wasTaxi
      outTaxi+=", "
    end
    wasTaxi=true
    outTaxi+=i.name
  end
  if i.pizzaElements==maxPizza
    if wasPizza
      outPizza+=", "
    end
    wasPizza=true
    outPizza+=i.name
  end
  if i.girlElements==maxGirl
    if wasGirl
      outGirl+=", "
    end
    wasGirl=true
    outGirl+=i.name
  end
end
outTaxi+="."
outPizza+="."
outGirl+="."
puts outTaxi
puts outPizza
puts outGirl

n = gets.to_i
CON = [:taxi,:pizza,:girl]
friends = []
names = []
n.times do
	m,name = gets.chomp.split(" ")
	names << name
	m = m.to_i
	nos = Hash.new(0)
	m.times do
		ans = nil
		x,y,z = gets.chomp.split("-")
		a,b,c = x.to_i,y.to_i,z.to_i
		arr = [x.split(''),y.split(''),z.split('')].flatten

		# puts "#{one} #{two} #{three} #{four} #{five} #{six}"
		# puts "#{b} #{c}"
		# puts "#{(one.to_i > two.to_i) && (three.to_i > four.to_i) && (five.to_i > six.to_i)}"
		if a == b && b == c && arr.each_cons(2).all?{|l,m| l == m}
			ans = CON[0]
		elsif a > b && b > c && arr.each_cons(2).all?{|l,m| l > m}
			ans = CON[1]
		else
			ans = CON[2]
		end
		nos[ans] += 1
	end
	friends << nos
end
taxi = []
pizza = []
girl = []
# puts "#{friends}"
friends.each_with_index do |f,i|
	taxi[i] = f[CON[0]]
	pizza[i] = f[CON[1]]
	girl[i] = f[CON[2]]
end

list = []
max = taxi.max
taxi.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to call a taxi, you should call: #{list.join(', ')}."

list = []
max = pizza.max
pizza.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to order a pizza, you should call: #{list.join(', ')}."

list = []
max = girl.max
girl.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to go to a cafe with a wonderful girl, you should call: #{list.join(', ')}."

#

def is_taxi(number)
  prev_char = ''
  taxi = true
  number.each_char do |char|
    taxi = false if (prev_char != '' && char != prev_char)
    prev_char = char
  end
  taxi
end

def is_pizza(number)
  prev_char = ''
  pizza = true
  number.each_char do |char|
    pizza = false if (prev_char != '' && char.to_i >= prev_char)
    prev_char = char.to_i
  end
  pizza
end

friends_count = gets.to_i

names = []
pizza_n = []
taxi_n = []
girl_n = []

pizza_max = 0
taxi_max = 0
girl_max = 0

friends_count.times do
  numbers_count, name = gets.split(' ')
  names << name
  taxi_count = 0
  pizza_count = 0
  numbers_count.to_i.times do
    number = gets.gsub('-', '').chomp
    prev_char = ''
    taxi_count += 1 if is_taxi number
    pizza_count += 1 if is_pizza number
  end
  girl_count = numbers_count.to_i - taxi_count - pizza_count

  girl_n << name if girl_count == girl_max
  girl_n = [name] if girl_count > girl_max
  girl_max = girl_count if girl_count >= girl_max

  taxi_n << name if taxi_count == taxi_max
  taxi_n = [name] if taxi_count > taxi_max
  taxi_max = taxi_count if taxi_count >= taxi_max

  pizza_n << name if pizza_count == pizza_max
  pizza_n = [name] if pizza_count > pizza_max
  pizza_max = pizza_count if pizza_count >= pizza_max
end

puts "If you want to call a taxi, you should call: " + taxi_n.join(', ') + "."
puts "If you want to order a pizza, you should call: " + pizza_n.join(', ') + "."
puts "If you want to go to a cafe with a wonderful girl, you should call: " + girl_n.join(', ') + "."

class Array
  def uniq?
    self.uniq.size == 1
  end

  def desc?
    (1...self.size).each { |i|
      return false if self[i] >= self[i - 1]
    }
    true
  end
end

people = {}

(0...gets.to_i).each {
  numbers_count, name = gets.chomp.split
  people[name] = Array.new(3, 0)
  (0...numbers_count.to_i).each {
    phone_digits = gets.chomp.gsub(/-/, '').split('').map(&:to_i)
    people[name][phone_digits.uniq? ? 0 : phone_digits.desc? ? 1 : 2] += 1
  }
}

['call a taxi', 'order a pizza', 'go to a cafe with a wonderful girl'].each_with_index { |action, index|
  max = people.values.map { |a| a[index] }.max
  printf "If you want to %s, you should call: %s.\n", action, people.select { |_, a| a[index] == max }.keys.join(', ')
}

t = STDIN.gets.to_i

ar = []

def taxi?(phone)
  !!(phone =~ /(.)\1-\1\1-\1\1/)
end

def pizza?(phone)
  phone.scan(/\d/).map(&:to_i).each_cons(2) {|a,b| return false if a <= b }
  return true
end

maxt, maxp, maxg = 0, 0, 0

t.times do
  n, name = STDIN.gets.chomp.split
  ntaxi, npizza, ngirl = 0, 0, 0

  n.to_i.times do

    phone = STDIN.gets.chomp

    if taxi?(phone)
      ntaxi += 1
    elsif pizza?(phone)
      npizza += 1
    else
      ngirl += 1
    end
  end

  ar << [name, ntaxi, npizza, ngirl]
  maxt = ntaxi if maxt < ntaxi
  maxp = npizza if maxp < npizza
  maxg = ngirl if maxg < ngirl

end

msg1 = "If you want to call a taxi, you should call: "
msg2 = "If you want to order a pizza, you should call: "
msg3 = "If you want to go to a cafe with a wonderful girl, you should call: "

ta = []
pa = []
ga = []

ar.each do |el|
  ta << el[0] if maxt == el[1]
  pa << el[0] if maxp == el[2]
  ga << el[0] if maxg == el[3]
end

puts msg1 << ta.join(", ") << "."
puts msg2 << pa.join(", ") << "."
puts msg3 << ga.join(", ") << "."

person = []
gets.to_i.times{ |i|
 a, b = gets.split
 person[i] = [b, 0, 0, 0]
 a.to_i.times{
  d = gets.gsub(/[^\d]/, "").split("").map(&:to_i)
  same, dec = true, true
  d.each_with_index{ |x,j|
   same = false if x != d[0]
   dec = false if j > 0 && x >= d[j-1]
  }
  if same
   person[i][1] += 1
  elsif dec
   person[i][2] += 1
  else
   person[i][3] += 1
  end
 }
}

mx = (1..3).map{ |i| person.max_by{ |e| e[i] }[i] }
["call a taxi" ,"order a pizza", "go to a cafe with a wonderful girl"].each_with_index{ |s,i|
 puts "If you want to " + s + ", you should call: " +
 person.select{ |e| e[i+1] == mx[i] }.map{ |e| e[0] }*", " + "."
}

def which_phone_no(numbers)
	return :taxi if numbers.uniq.size==1
	return :pizza if numbers.each_cons(2).all?{|a,b|a>b}
	return :girl
end
call={}
k=[:taxi,:pizza,:girl]
k.each{|_k|call[_k]=[0,[]]}
gets.to_i.times{
	s,name=gets.split
	books=s.to_i.times.map{which_phone_no(gets.scan(/[0-9]/).map(&:to_i))}
	k.each{|_k|
		m=books.count(_k)
		if m>call[_k][0]
			call[_k][0]=m
			call[_k][1]=[name]
		elsif call[_k][0]==m
			call[_k][1]<<name
		end
	}
}
puts "If you want to call a taxi, you should call: %s."%(call[:taxi][1]*", ")
puts "If you want to order a pizza, you should call: %s."%(call[:pizza][1]*", ")
puts "If you want to go to a cafe with a wonderful girl, you should call: %s."%(call[:girl][1]*", ")

res = {:taxi => Hash.new(0), :pizza => Hash.new(0), :girl => Hash.new(0)}
sum = {:taxi => [], :pizza => [], :girl => []}
names = []

class String
	def which?
		n = self.gsub('-', '')
		n = n.split('').map &:to_i
		if    n.count == n.count(n[0])
			'taxi'
		elsif       n == n.uniq.sort.reverse
			'pizza'
		else
			'girl'
		end
	end
end

gets; while g = gets
	g = g.chop.split
	n = g[0].to_i
	names.push g[1].to_sym
	n.times do
		num = gets.chop!
		res[num.which?.to_sym][g[1].to_sym] += 1
	end
end

res.each do |key, hash|
	max = hash.values.max
	hash.each { |k, v| sum[key].push(k) if v == max }
end

{
	:taxi => 'call a',
	:pizza => 'order a',
	:girl => 'go to a cafe with a wonderful'
}.each do |k, v|
	print "If you want to #{v} #{k}, you should call: "
	print sum[k].empty? ? names.join(', ') : sum[k].join(', ')
	puts "."
end

#! /usr/bin/env ruby

t = gets.chomp.to_i
d = {}
name_list = []
(1..t).each do |x|
  n, name = gets.chomp.split
  n = n.to_i
  d[name] = {}
  name_list << name
  (1..n).each do |y|
    num = gets.chomp.split("-")
    if num.uniq.size == 1 and num.uniq.first.split(//).uniq.size == 1
      d[name]['taxi'] = (d[name]['taxi'] || 0) + 1
    elsif num.join.split(//).map(&:to_i) == num.join.split(//).map(&:to_i).sort.reverse.uniq
      d[name]['pizza'] = (d[name]['pizza'] || 0) + 1
    else
      d[name]['girl'] = (d[name]['girl'] || 0) + 1
    end
  end
end
max_taxi = d.keys.map { |i| [d[i]['taxi'] || 0, i] }.sort.max.first
max_pizza = d.keys.map { |i| [d[i]['pizza'] || 0, i] }.sort.max.first
max_girl = d.keys.map { |i| [d[i]['girl'] || 0, i] }.sort.max.first
taxi = name_list.select {|i| d[i]['taxi'] == max_taxi }.join(", ") + "."
pizza = name_list.select {|i| d[i]['pizza'] == max_pizza }.join(", ") + "."
girl = name_list.select {|i| d[i]['girl'] == max_girl }.join(", ") + "."
print ("If you want to call a taxi, you should call: " + taxi +"\n").to_s
print ("If you want to order a pizza, you should call: " + pizza +"\n").to_s
print ("If you want to go to a cafe with a wonderful girl, you should call: " + girl +"\n").to_s

#! /usr/bin/env ruby

def type_of_phone_number(number)
  return :taxi if number.uniq.size.equal? 1
  return :pizza if number.each_cons(2).all? {|x, y| x > y}
  return :girl
end

d = {}
k = [:taxi, :pizza, :girl]
k.each {|x| d[x] = [0, []]}

gets.to_i.times do |x|
  n, name = gets.chomp.split
  numbers = n.to_i.times.map {type_of_phone_number(gets.scan(/[0-9]/).map(&:to_i))}
  k.each do |x|
    d[x] = [numbers.count(x), [name]] if numbers.count(x) > d[x].first
    d[x].last << name if numbers.count(x) > d[x].first
  end
end

puts "If you want to call a taxi, you should call: %s." %(d[:taxi][1] * ", ")
puts "If you want to order a pizza, you should call: %s." %(d[:pizza][1] * ", ")
puts "If you want to go to a cafe with a wonderful girl, you should call: %s." %(d[:girl][1] * ", ")

#! /usr/bin/env ruby

def type_of_phone_number(number)
  return :taxi if number.uniq.size.equal? 1
  return :pizza if number.each_cons(2).all? {|x, y| x > y}
  return :girl
end

d = {}
k = [:taxi, :pizza, :girl]
k.each {|x| d[x] = [0, []]}

gets.to_i.times do |x|
  n, name = gets.chomp.split
  numbers = n.to_i.times.map {type_of_phone_number(gets.scan(/[0-9]/).map(&:to_i))}
  k.each do |x|
    d[x] = [numbers.count(x), [name]] if numbers.count(x) > d[x].first
    d[x].last << name if numbers.count(x) > d[x].first
  end
end

p "If you want to call a taxi, you should call: %s." %(d[:taxi][1] * ", ")
p "If you want to order a pizza, you should call: %s." %(d[:pizza][1] * ", ")
p "If you want to go to a cafe with a wonderful girl, you should call: %s." %(d[:girl][1] * ", ")

#! /usr/bin/env ruby

t = gets.chomp.to_i
d = {}
name_list = []
(1..t).each do |x|
  n, name = gets.chomp.split
  n = n.to_i
  d[name] = {}
  name_list << name
  (1..n).each do |y|
    num = gets.chomp.split("-")
    if num.uniq.size == 1 and num.uniq.first.split(//).uniq.size == 1
      d[name]['taxi'] = (d[name]['taxi'] || 0) + 1
    elsif num.join.split(//).map(&:to_i) == num.join.split(//).map(&:to_i).sort.reverse.uniq
      d[name]['pizza'] = (d[name]['pizza'] || 0) + 1
    else
      d[name]['girl'] = (d[name]['girl'] || 0) + 1
    end
  end
end
max_taxi = d.keys.map { |i| [d[i]['taxi'] || 0, i] }.sort.max.first
max_pizza = d.keys.map { |i| [d[i]['pizza'] || 0, i] }.sort.max.first
max_girl = d.keys.map { |i| [d[i]['girl'] || 0, i] }.sort.max.first
taxi = name_list.select {|i| d[i]['taxi'] == max_taxi }.join(", ") + "."
pizza = name_list.select {|i| d[i]['pizza'] == max_pizza }.join(", ") + "."
girl = name_list.select {|i| d[i]['girl'] == max_girl }.join(", ") + "."
p ("If you want to call a taxi, you should call: " + taxi).to_s.strip
p "If you want to order a pizza, you should call: " + pizza
p "If you want to go to a cafe with a wonderful girl, you should call: " + girl

require 'set'

def is_taxi(s)
  tmp = s.split "-"
  set = Set.new tmp
  if set.length == 1
    true
  else
    false
  end
end

def is_pizza(s)
  flag = true
  tmp = nil
  s.split("").each do |c|
    if c != '-'
      if tmp == nil
        tmp = c.to_i
      else
        if tmp <= c.to_i
          flag = false
          break
        else
          tmp = c.to_i
        end
      end
    end
  end
  flag
end

def max_names(hash)
  max = hash.values.max
  names = hash.select{ |k, v|
    v == max
  }
  names.keys.join ', '
end

n = gets.chomp.to_i

taxi = {}
pizza = {}
girl = {}

n.times do
  tmp = gets.chomp.split " "
  s = tmp[0].to_i
  name = tmp[1]

  taxi[name] = 0
  pizza[name] = 0
  girl[name] = 0

  s.times do
    tmp2 = gets.chomp
    if is_taxi(tmp2)
      taxi[name] += 1
    elsif is_pizza(tmp2)
      pizza[name] += 1
    else
      girl[name] += 1
    end
  end
end

puts "If you want to call a taxi, you should call: " + max_names(taxi) + "."
puts "If you want to order a pizza, you should call: " + max_names(pizza) + "."
puts "If you want to go to a cafe with a wonderful girl, you should call: " + max_names(girl) + "."

def pizza?(num)
  num = num.gsub(/-/,'').chars.map(&:to_i)
  prev = 10
  num.each do |n|
    if prev > n
      prev = n
    else
      return false
    end
  end
  true
end

def taxi?(num)
  a = num[0]
  num.gsub(/[#{a}\-]/,'').size.zero?
end

def girl?(num)
  !taxi?(num) && !pizza?(num)
end

def which(num)
  return :taxi if taxi?(num)
  return :pizza if pizza?(num)
  return :girl
end

dics = {}
n = STDIN.gets.chomp.to_i
n.times do
  i, name = STDIN.gets.chomp.split(/ /)
  i = i.to_i
  dics[name] = {taxi: 0, pizza: 0, girl: 0}
  already = []

  i.times do
    num = STDIN.gets.chomp
    next if already.include?(num)
    already << num
    dics[name][which(num)] += 1
  end
end

{taxi: "If you want to call a taxi, you should call: ",
 pizza: "If you want to order a pizza, you should call: ",
 girl: "If you want to go to a cafe with a wonderful girl, you should call: "}.each do |type, head|
  max = dics.map{|k,v| v[type] }.max
  puts head+dics.select{|k,v| v[type] == max }.keys.join(", ")+"."
end

def pizza?(num)
  num = num.gsub(/-/,'').chars.map(&:to_i)
  prev = 10
  num.each do |n|
    if prev > n
      prev = n
    else
      return false
    end
  end
  true
end

def taxi?(num)
  a = num[0]
  num.gsub(/[#{a}\-]/,'').size.zero?
end

def girl?(num)
  !taxi?(num) && !pizza?(num)
end

def which(num)
  return :taxi if taxi?(num)
  return :pizza if pizza?(num)
  return :girl
end

dics = {}
n = STDIN.gets.chomp.to_i
n.times do
  i, name = STDIN.gets.chomp.split(/ /)
  i = i.to_i
  dics[name] = {taxi: 0, pizza: 0, girl: 0}
  already = []

  i.times do
    num = STDIN.gets.chomp
    next if already.include?(num)
    already << num
    dics[name][which(num)] += 1
  end
end

{taxi: "If you want to call a taxi, you should call: ",
 pizza: "If you want to order a pizza, you should call: ",
 girl: "If you want to go to a cafe with a wonderful girl, you should call: "}.each do |type, head|
  max = dics.max{|(k,v)| v[type] }[1][type]
  puts head+dics.select{|k,v| v[type] == max }.keys.join(", ")+"."
end

def pizza?(num)
  num = num.gsub(/-/,'').chars.map(&:to_i)
  prev = 10
  num.each do |n|
    if prev > n
      prev = n
    else
      return false
    end
  end
  true
end

def taxi?(num)
  a = num[0]
  num.gsub(/[#{a}\-]/,'').size.zero?
end

def girl?(num)
  !taxi?(num) && !pizza?(num)
end

def which(num)
  return :taxi if taxi?(num)
  return :pizza if pizza?(num)
  return :girl
end

dics = {}
n = STDIN.gets.chomp.to_i
n.times do
  i, name = STDIN.gets.chomp.split(/ /)
  i = i.to_i
  dics[name] = {taxi: 0, pizza: 0, girl: 0}
  already = []

  i.times do
    num = STDIN.gets.chomp
    next if already.include?(num)
    already << num
    dics[name][which(num)] += 1
  end
end

{taxi: "If you want to call a taxi, you should call: ",
 pizza: "If you want to order a pizza, you should call: ",
 girl: "If you want to go to a cafe with a wonderful girl, you should call: "}.each do |type, head|
  max = dics.max{|(k,v)| v[type] }[1][type]
  puts head+dics.select{|k,v| v[type] == max }.keys.join(", ")
end

n = gets.to_i
pb = []
n.times do |i|
  a  = [i]
  c,nm = gets.split
  a << nm
  h = Hash.new(0)
  c.to_i.times do
    pn = gets.strip.gsub(/-/,"").split(//)
    pn.uniq.sort.reverse
    if pn.uniq.size == 1
      h[:t] += 1
    elsif pn.uniq.sort.reverse == pn
      h[:p] += 1
    else
      h[:g] += 1
    end
  end
  a << h
  pb << a
end

mx = pb.map{|a| a[2][:t]}.max
tx = pb.select{|a| a[2][:t] == mx }

mx = pb.map{|a| a[2][:p]}.max
pz = pb.select{|a| a[2][:p] == mx }

mx = pb.map{|a| a[2][:g]}.max
gf = pb.select{|a| a[2][:g] == mx }

puts "If  want to order a pizza, you should call: #{tx.map{|a| a[1]}.join(", ")}."
puts "If you want to call a taxi, you should call: #{pz.map{|a| a[1]}.join(", ")}."
puts "If you want to go to a cafe with a wonderful girl, you should call: #{gf.map{|a| a[1]}.join(", ")}."

#!/usr/bin/ruby
class Number
  def initialize
  @mas=Array.new(6)
  end
  def mas
    @mas
  end
  def mas=(mas)
    @mas=mas
  end
  def isPizza()
    return @mas==@mas.uniq() && @mas==@mas.sort{|a,b| b<=>a}
  end
  def isTaxi()
     return @mas.uniq().size()==1
  end
end
class Person
  def initialize
  @name=""
  @taxiElements=0
  @girlElements=0
  @pizzaElements=0
  @numberArray=[]
  end
  def taxiElements
    @taxiElements
  end
  def pizzaElements
    @pizzaElements
  end
  def girlElements
    @girlElements
  end
  def name
    @name
  end
  def name=(name)
    @name=name
  end
  def numberArray
    @numberArray
  end
  def numberArray=(numberArray)
    @numberArray=numberArray
  end
  def countElements()
    for i in 0..(@numberArray.size()-1)
      element=@numberArray[i]
     if element.isTaxi()
	@taxiElements=@taxiElements+1
     elsif (element.isPizza())
	@pizzaElements=@pizzaElements+1
     else
	@girlElements=@girlElements+1
      end
    end
  end
end

require 'scanf'
count=(scanf("%d"))[0]
array=Array.new(count)
for i in 0..(count-1)
  array[i]=Person.new
  temp=scanf("%d %s")
  elements=temp[0]
  array[i].name=temp[1]
  array[i].numberArray=Array.new(elements)
  for j in 0..(elements-1)
    array[i].numberArray[j]=Number.new
    array[i].numberArray[j].mas=scanf("%c%c-%c%c-%c%c")
  end

end

array.each do |i|
  i.countElements()
end
maxPizza=(array.map{|x|x.pizzaElements}).max
maxTaxi=(array.map{|x|x.taxiElements}).max
maxGirl=(array.map{|x|x.girlElements}).max
outTaxi="If you want to call a taxi, you should call: "
outPizza="If you want to order a pizza, you should call: "
outGirl="If you want to go to a cafe with a wonderful girl, you should call: "
wasTaxi=false
wasPizza=false
wasGirl=false
array.each do |i|
  if i.taxiElements==maxTaxi
    if wasTaxi
      outTaxi+=", "
    end
    wasTaxi=true
    outTaxi+=i.name
  end
  if i.pizzaElements==maxPizza
    if wasPizza
      outPizza+=", "
    end
    wasPizza=true
    outPizza+=i.name
  end
  if i.girlElements==maxGirl
    if wasGirl
      outGirl+=", "
    end
    wasGirl=true
    outGirl+=i.name
  end
end
outTaxi+="."
outPizza+="."
outGirl+="."
if wasTaxi
  puts outTaxi
end
if wasPizza
  puts outPizza
end
if wasGirl
  puts outGirl
end

#!/usr/bin/ruby
class Number
  def initialize
  @mas=Array.new(6)
  end
  def mas
    @mas
  end
  def mas=(mas)
    @mas=mas
  end
  def isPizza()
    return @mas==@mas.uniq() && @mas==@mas.sort{|a,b| b<=>a}
  end
  def isTaxi()
     return @mas.uniq().size()==1
  end
end
class Person
  def initialize
  @name=String.new
  @taxiElements=0
  @girlElements=0
  @pizzaElements=0
  @numberArray=[]
  end
  def taxiElements
    @taxiElements
  end
  def pizzaElements
    @pizzaElements
  end
  def girlElements
    @girlElements
  end
  def name
    @name
  end
  def name=(name)
    @name=name
  end
  def numberArray
    @numberArray
  end
  def numberArray=(numberArray)
    @numberArray=numberArray
  end
  def countElements()
    for i in 0..(@numberArray.size()-1)
      element=@numberArray[i]
     if element.isTaxi()
    @taxiElements=@taxiElements+1
     elsif (element.isPizza())
    @pizzaElements=@pizzaElements+1
     else
    @girlElements=@girlElements+1
      end
    end
  end
end

require 'scanf'
count=(scanf("%d\n"))[0]
array=Array.new(count)
for i in 0..(count-1)
  array[i]=Person.new
  temp=scanf("%d %s\n")
  puts  temp
  elements=temp[0]
  array[i].name=temp[1]
  array[i].numberArray=Array.new(elements)
  for j in 0..(elements-1)
    array[i].numberArray[j]=Number.new
    array[i].numberArray[j].mas=scanf("%c%c-%c%c-%c%c\n")
  end

end

array.each do |i|
  i.countElements()
end
maxPizza=(array.map{|x|x.pizzaElements}).max
maxTaxi=(array.map{|x|x.taxiElements}).max
maxGirl=(array.map{|x|x.girlElements}).max
outTaxi="If you want to call a taxi, you should call: "
outPizza="If you want to order a pizza, you should call: "
outGirl="If you want to go to a cafe with a wonderful girl, you should call: "
wasTaxi=false
wasPizza=false
wasGirl=false
array.each do |i|
  if i.taxiElements==maxTaxi
    if wasTaxi
      outTaxi+=", "
    end
    wasTaxi=true
    outTaxi+=i.name
  end
  if i.pizzaElements==maxPizza
    if wasPizza
      outPizza+=", "
    end
    wasPizza=true
    outPizza+=i.name
  end
  if i.girlElements==maxGirl
    if wasGirl
      outGirl+=", "
    end
    wasGirl=true
    outGirl+=i.name
  end
end
outTaxi+="."
outPizza+="."
outGirl+="."
puts outTaxi
puts outPizza
puts outGirl

#!/usr/bin/ruby
class Number
  def initialize
  @mas=Array.new(6)
  end
  def mas
    @mas
  end
  def mas=(mas)
    @mas=mas
  end
  def isPizza()
    return @mas==@mas.uniq() && @mas==@mas.sort{|a,b| b<=>a}
  end
  def isTaxi()
     return @mas.uniq().size()==1
  end
end
class Person
  def initialize
  @name=""
  @taxiElements=0
  @girlElements=0
  @pizzaElements=0
  @numberArray=[]
  end
  def taxiElements
    @taxiElements
  end
  def pizzaElements
    @pizzaElements
  end
  def girlElements
    @girlElements
  end
  def name
    @name
  end
  def name=(name)
    @name=name
  end
  def numberArray
    @numberArray
  end
  def numberArray=(numberArray)
    @numberArray=numberArray
  end
  def countElements()
    for i in 0..(@numberArray.size()-1)
      element=@numberArray[i]
     if element.isTaxi()
	@taxiElements=@taxiElements+1
     elsif (element.isPizza())
	@pizzaElements=@pizzaElements+1
     else
	@girlElements=@girlElements+1
      end
    end
  end
end

require 'scanf'
count=(scanf("%d"))[0]
array=Array.new(count)
for i in 0..(count-1)
  array[i]=Person.new
  temp=scanf("%d %s")
  elements=temp[0]
  array[i].name=temp[1]
  array[i].numberArray=Array.new(elements)
  for j in 0..(elements-1)
    array[i].numberArray[j]=Number.new
    array[i].numberArray[j].mas=scanf("%c%c-%c%c-%c%c")
  end

end

array.each do |i|
  i.countElements()
end
maxPizza=(array.map{|x|x.pizzaElements}).max
maxTaxi=(array.map{|x|x.taxiElements}).max
maxGirl=(array.map{|x|x.girlElements}).max
outTaxi="If you want to call a taxi, you should call: "
outPizza="If you want to order a pizza, you should call: "
outGirl="If you want to go to a cafe with a wonderful girl, you should call: "
wasTaxi=false
wasPizza=false
wasGirl=false
array.each do |i|
  if i.taxiElements==maxTaxi
    if wasTaxi
      outTaxi+=", "
    end
    wasTaxi=true
    outTaxi+=i.name
  end
  if i.pizzaElements==maxPizza
    if wasPizza
      outPizza+=", "
    end
    wasPizza=true
    outPizza+=i.name
  end
  if i.girlElements==maxGirl
    if wasGirl
      outGirl+=", "
    end
    wasGirl=true
    outGirl+=i.name
  end
end
outTaxi+="."
outPizza+="."
outGirl+="."
puts outTaxi
puts outPizza
puts outGirl

n = gets.to_i
CON = [:taxi,:pizza,:girl]
friends = []
names = []
n.times do
	m,name = gets.chomp.split(" ")
	names << name
	m = m.to_i
	nos = Hash.new(0)
	m.times do
		ans = nil
		x,y,z = gets.chomp.split("-")
		a,b,c = x.to_i,y.to_i,z.to_i
		arr = [x.split(''),y.split(''),z.split('')].flatten

		# puts "#{one} #{two} #{three} #{four} #{five} #{six}"
		# puts "#{b} #{c}"
		# puts "#{(one.to_i > two.to_i) && (three.to_i > four.to_i) && (five.to_i > six.to_i)}"
		if a == b && b == c && arr.each_cons(2).all?{|l,m| l == m}
			ans = CON[0]
		elsif a > b && b > c && arr.each_cons(2).all?{|l,m| l > m}
			ans = CON[1]
		else
			ans = CON[2]
		end
		nos[ans] += 1
	end
	friends << nos
end
taxi = []
pizza = []
girl = []
puts "#{friends}"
friends.each_with_index do |f,i|
	taxi[i] = f[CON[0]]
	pizza[i] = f[CON[1]]
	girl[i] = f[CON[2]]
end

list = []
max = taxi.max
taxi.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to call a taxi, you should call: #{list.join(', ')}."

list = []
max = pizza.max
pizza.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to order a pizza, you should call: #{list.join(', ')}."

list = []
max = girl.max
girl.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to go to a cafe with a wonderful girl, you should call: #{list.join(', ')}."

n = gets.to_i
CON = [:taxi,:pizza,:girl]
friends = []
names = []
n.times do
	m,name = gets.chomp.split(" ")
	names << name
	m = m.to_i
	nos = Hash.new(0)
	m.times do
		ans = nil
		x,y,z = gets.chomp.split("-")
		a,b,c = x.to_i,y.to_i,z.to_i
		one,two = x.split('')
		three,four = y.split('')
		five,six = z.split('')
		# puts "#{one} #{two} #{three} #{four} #{five} #{six}"
		# puts "#{b} #{c}"
		# puts "#{(one.to_i > two.to_i) && (three.to_i > four.to_i) && (five.to_i > six.to_i)}"
		if a == b && b == c
			ans = CON[0]
		elsif a > b && b > c && (one.to_i > two.to_i) && (three.to_i > four.to_i) && (five.to_i > six.to_i)
			ans = CON[1]
		else
			ans = CON[2]
		end
		nos[ans] += 1
	end
	friends << nos
end
taxi = []
pizza = []
girl = []

friends.each_with_index do |f,i|
	taxi[i] = f[CON[0]]
	pizza[i] = f[CON[1]]
	girl[i] = f[CON[2]]
end

list = []
max = taxi.max
taxi.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to call a taxi, you should call: #{list.join(', ')}."

list = []
max = pizza.max
pizza.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to order a pizza, you should call: #{list.join(', ')}."

list = []
max = girl.max
girl.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to go to a cafe with a wonderful girl, you should call: #{list.join(', ')}."

n = gets.to_i
CON = [:taxi,:pizza,:girl]
friends = []
names = []
n.times do
	m,name = gets.chomp.split(" ")
	names << name
	m = m.to_i
	nos = Hash.new(0)
	m.times do
		ans = nil
		x,y,z = gets.chomp.split("-")
		a,b,c = x.to_i,y.to_i,z.to_i
		arr = [x.split(''),y.split(''),z.split('')].flatten

		# puts "#{one} #{two} #{three} #{four} #{five} #{six}"
		# puts "#{b} #{c}"
		# puts "#{(one.to_i > two.to_i) && (three.to_i > four.to_i) && (five.to_i > six.to_i)}"
		if a == b && b == c
			ans = CON[0]
		elsif a > b && b > c && arr.each_cons(2).all?{|l,m| l > m}
			ans = CON[1]
		else
			ans = CON[2]
		end
		nos[ans] += 1
	end
	friends << nos
end
taxi = []
pizza = []
girl = []
# puts "#{friends}"
friends.each_with_index do |f,i|
	taxi[i] = f[CON[0]]
	pizza[i] = f[CON[1]]
	girl[i] = f[CON[2]]
end

list = []
max = taxi.max
taxi.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to call a taxi, you should call: #{list.join(', ')}."

list = []
max = pizza.max
pizza.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to order a pizza, you should call: #{list.join(', ')}."

list = []
max = girl.max
girl.each_with_index do |t,i|
	list << names[i] if t == max
end

puts "If you want to go to a cafe with a wonderful girl, you should call: #{list.join(', ')}."

person = []
gets.to_i.times{ |i|
 a, b = gets.split
 person[i] = [b, 0, 0, 0]
 a.to_i.times{
  d = gets.gsub(/[^\d]/, "").split("").map(&:to_i)
  same, dec = true, true
  d.each_with_index{ |x,j|
   same = false if x != d[0]
   dec = false if j > 0 && x >= d[j-1]
  }
  if same
   person[i][1] += 1
  elsif dec
   person[i][2] += 1
  else
   person[i][3] += 1
  end
 }
}

mx = (1..3).map{ |i| person.max_by{ |e| e[i] }[i] }
["taxi" ,"pizza", "cafe with a wonderful girl"].each_with_index{ |s,i|
 puts "If you want to call a " + s + ", you should call: " +
 person.select{ |e| e[i+1] == mx[i] }.map{ |e| e[0] }*", " + "."
}

res = {:taxi => Hash.new(0), :pizza => Hash.new(0), :girl => Hash.new(0)}
sum = {:taxi => [], :pizza => [], :girl => []}

class String
	def which?
		n = self.gsub('-', '')
		n = n.split('').map &:to_i
		if    n.count == n.count(n[0])
			'taxi'
		elsif       n == n.uniq.sort.reverse
			'pizza'
		else
			'girl'
		end
	end
end

gets; while g = gets
	g = g.chop.split
	g[0].to_i.times do |i|
		num = gets.chop!
		res[num.which?.to_sym][g[1].to_sym] += 1
	end
end

res.each do |key, hash|
	max = hash.values.max
	hash.each { |k, v| sum[key].push(k) if v == max }
end

{
	:taxi => 'call a',
	:pizza => 'order a',
	:girl => 'go to a cafe with a wonderful'
}.each do |k, v|
	print "If you want to #{v} #{k}, you should call: "
	print sum[k].join(', ')
	puts "."
end


n = gets.to_i
str1 = gets.chomp
str2 = gets.chomp

#require 'Set'

count = 0

(0..(n/2)-1).each do |i|
  set = [str1[i],str2[i],str1[n-i-1],str2[n-i-1]]
  len = set.uniq.length

  if len == 2
    if set.count(set[0]) != 2
      count += 1
    end
  elsif len == 3
    count += 1
    if set[0] == set[2]
      count += 1
    end
  elsif len == 4
    count += 2
  end
end

if n%2==1
  if str1[n/2]!=str2[n/2]
    count += 1
  end
end

puts count

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif B[i] != B[N-i-1] && A[i] != B[i] && A[N-i-1] != B[N-i-1] && A[i] != B[N-i-1] && A[N-i-1] != B[i]
        ans += 2
    else
        ans += 1
    end
end
puts ans

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif B[i] != B[N-i-1] && A[i] != B[i] && A[N-i-1] != B[N-i-1]
        ans += 2
    else
        ans += 1
    end
    p [i, ans]
end
puts ans

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif values == [1, 3] || B[i] == B[N-i-1]
        ans += 1
    else
        ans += 2
    end
end
puts ans

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif B[i] != B[N-i-1] && A[i] != B[i] && A[N-i-1] != B[N-i-1] && A[i] != B[N-i-1] && A[N-i-1] && B[i]
        ans += 2
    else
        ans += 1
    end
end
puts ans

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif A[i] != A[N-i-1] && A[i] != B[i] && A[N-i-1] != B[N-i-1]
        ans += 2
    else
        ans += 1
    end
end
puts ans

N = gets.to_i
A = gets.chomp
B = gets.chomp

ans = 0
((N+1)/2).times do |i|
    hash = Hash.new(0)
    hash[A[i]] += 1
    hash[B[i]] += 1
    if i != N-i-1
        hash[A[N-i-1]] += 1
        hash[B[N-i-1]] += 1
    end
    values = hash.values.sort
    if values.all?(&:even?)
        next
    elsif B[i] != B[N-i-1] && A[i] != B[i] && A[N-i-1] != B[N-i-1]
        ans += 2
    else
        ans += 1
    end
end
puts ans


n = gets.to_i
a = gets.split(/\s+/).map(&:to_i).sort_by {|e| -e}
sum = result = a.inject {|a,b| a+b}

while a.size > 1
  x = a.pop
  result += sum
  sum -= x
end

p result

n = gets.to_i
puts gets.chomp.split.map(&:to_i).sort.each_with_index.map{|x, i| x * (if i == n - 1 then i + 1 else i + 2 end)}.inject(:+)

n=gets.to_i
v=(gets.split.map &:to_i).sort
x=-v[-1]
(0...n).each{|i| x += (i+2)*v[i]}
p x

gets
x=gets.split.map{|e| e.to_i}.sort

sum1=x.inject(0){|sumA,e|
	sumA+e
}
ans=0
while x.size>1
	ans+=sum1
	sum1-=x[0]
	ans+=x[0]
	x.shift
end
ans+=x[0]
puts ans

#!/usr/bin/ruby2.0

n = STDIN.readline.to_i
numbers = STDIN.readline.split.collect {|s| s.to_i }
numbers.sort!

score = -numbers[n-1]
(n.downto 1).each do |i|
	score += (i+1)*numbers[i-1]
end

puts score

n = gets.to_i
vec = (gets.split.map &:to_i).sort
x = 2*vec.reduce(:+) - vec[n-1]
for i in (1...n)
  x += i*vec[i]
end
p x

n=gets.to_i
v=(gets.split.map &:to_i).sort
x=2*v.reduce(:+)-v[-1]
(1...n).each{|i| x+=i*v[i]}
p x

N = gets.to_i
sum = 0
arr = gets.split.map{ |xx|
  x = xx.to_i
  sum += x
  x
}.sort_by{|x|x}
# p arr
# p sum
ans = sum
(N-1).times do |i|
  ans += sum
  sum -= arr[i]
  # p ans
end
puts ans

require 'pp'

n = STDIN.gets.chomp.to_i
vals = STDIN.gets.chomp.split(/ /).map(&:to_i)
vals.sort!.reverse!
ans = - vals.first
vals.each do |val|
  ans += val * (n + 1)
  n -= 1
end

puts ans

# coding: utf-8

n = gets.to_i
ar = gets.split.map(&:to_i)
ar.sort!

# 1 2 3 4 5
# X X X X X  sum [1 2 3 4 5]
# X X X X X  sp rt sum [1] [2 3 4 5]
# ? X X X X  throw sp rt sum [2] [3 4 5]
# ? ? X X X  throw sp rt sum [3] [4, 5]
# ? ? ? ? ?
# 1 3 5
# X X X [1 3 5]
# X X X [1] [3 5]
# ? X X [3] [5]
# ? ? ? empty
# 1 2 3 4
# X X X X [1 2 3 4]
# X X X X [1] [2 3 4]
# ? X X X [2] [3 4]
# ? ? X X [3] [4]

s = ar.sum
acc = s
while s > 0
    if ar.length > 1
        acc += s
        s -= ar.shift
    else
        break
    end
end

puts acc

n, v, r = gets.to_i, gets.split.map {|e| e.to_i}.sort!, 0
for i in 0...n-1
    r+=v[i]*(i+2)
end
p r+v[-1]*n

n = Integer(gets.chomp)
v = gets.chomp.split.map{|x| Integer(x)}.sort
sum = 0
for x in v do sum += x end
ans = sum
for x in v[0...-1] do
    ans += sum
    sum -= x
end

puts ans

M = 1_000_000_007
n = gets.to_i
xs = gets.split.map(&:to_i)
xs.sort!
sum = 0
n.times do |i|
  sum += xs[i] * [i + 2, n].min
end
p sum

n=gets.to_i
arr=Array.new()
arr=gets.split.map(&:to_i)

arr.sort!
sum=arr[n-1]*n
for i in 2..n do
    sum+=arr[n-i]*(n+2-i)
end

puts sum

n = gets.to_i
tab = gets.split.map(&:to_i).sort

suffix_sum = tab[0..-2].reverse.inject([tab[-1]]){|x, y| x << x[-1]+y}.reverse

result = -tab[-1];

(0..tab.size-1).each do |i|
    result += suffix_sum[i] + tab[i]
end

puts result

# 3
# 3 1 5

n = gets.to_i
array_a = gets.split.map(&:to_i)

array_a.sort!

ans = 0

array_a.each_with_index do |a, i|
  break if i == n-1
  ans += a * (i+2)
end
ans += array_a.last * n

puts ans

n=gets.to_i
arr=gets.split(/ /).map(&:to_i)
sum=0
arr.each do |i|
  sum+=i
end
ans=0
arr.sort.each do |i|
  ans+=sum+i
  sum-=i
end
puts ans-arr.sort[-1]

# coding: utf-8

n = gets.to_i
ar = gets.split.map(&:to_i)
ar.sort!

# 1 2 3 4 5
# X X X X X  [1 2 3 4 5]
# X X X X X  [1] [2 3 4 5]
# ? X X X X  [2] [3 4 5]
# ? X X X X  [2] [3] [4] [5]
# ? ? ? ? ?
# 1 3 5
# X X X [1 3 5]
# X X X [1] [3 5]
# ? X X [3] [5]
# ? ? ? empty
# 1 2 3 4
# X X X X [1 2 3 4]
# X X X X [1] [2 3 4]
# ? X X X [2 3 4]
# ? X X X [2] [3 4]
# ? ? X X [3 4]
# ? ? X X [3] [4]

s = ar.sum
acc = 0
while s > 0
    acc += s
    if ar.length > 2 # 왜냐면 2에선 split 된 다음이 없기 때문
        acc += s
        sub = ar.shift
        s -= sub
    else
        break
    end
end

puts acc