while s = gets
  (h,w)=s.split(/ /).map(&:to_i)

  break if h+w==0

  (f,g,x,y)=[[],[],0,0]
  h.times{ f.push(gets.chomp.split(//)) }

  loop do
    if f[y][x] == "."
      puts "#{x} #{y}"
      break
    end

    if g.include?([x,y])
      puts "LOOP"
      break
    end

    g.push([x,y])
    case f[y][x]
    when ">" then x+=1
    when "<" then x-=1
    when "v" then y+=1
    when "^" then y-=1
    end
  end
end