@memo={}
def F x
  return @memo[x] if @memo[x]
  return @memo[x]=if x%2==1
                   x*3+1
                 else
                   x/2
                 end
end

def G t
  tt=t
  n=0
  until tt==1
    tt=F(tt)
    n+=1
  end
  n
end

def H n
  m_t=-1
  m_gt=-1
  (5..n).each{|t|
    gt=G(t)
    if m_gt < gt
      m_gt=gt
      m_t=t
    end
  }
  [m_t,m_gt]
end

if __FILE__==$0
  while gets
    puts H($_.to_i).join(', ')
  end
end
