while xy = gets.chomp
  break if xy == "0 0"
  x = xy.split[0].to_i
  m = []
  x.times{|i|
    m[i] = gets.chomp.split("")
  }
  i = 0
  j = 0
  done = {}
  loop do
    done[[i,j]] = true
    case m[i][j]
    when ">"
      j += 1
    when "<"
      j -= 1
    when "^"
      i -= 1
    when "v"
      i += 1
    when "."
      puts "#{j} #{i}"
      break
    end
    if done[[i,j]]
      puts "LOOP"
      break
    end
  end
end