d = Hash[*%w(^ v < >).zip([[-1, 0], [1, 0], [0, -1], [0, 1]]).flatten(1)]

loop {
    m, n = gets.split.map &:to_i
    break if m == 0

    a = (1..m).map{ gets.scan /./ }

    y, x = 0, 0
    reached = {[0, 0] => 0}
    loop {
        if !d[a[y][x]]
            puts [x, y] * ' ' 
            break
        end
        dy, dx = d[a[y][x]]
        y += dy
        x += dx
        if reached[[y, x]] 
            puts 'LOOP'
            break
        end
        reached[[y, x]] = 0 
    }   
}