import Control.Applicative ((<$>))
import Control.Monad (replicateM,unless)
import Control.Monad.State
import Data.Array.IArray
import Data.Array.IO

type Field = Array Position Char
type VisitField = IOArray Position Bool
type Position = (Int, Int)
type SearchState = (Field, VisitField, Position)
type SearchAction = StateT SearchState IO

main = do
    [h,w] <- map read.words<$>getLine
    unless (h == 0) $ do
                field  <- getField h w
                vfield <- newArray ((0,0),(h,w)) False
                position <- evalStateT searchGoal (field,vfield,(0,0))
                printResult position
                main

printResult pos
  | pos == (-1, -1) = putStrLn "LOOP"
  | otherwise       = putStrLn.unwords.map show $ [snd pos, fst pos]
                      
getField :: Int -> Int -> IO Field
getField h w = do
  tiles <- replicateM h getLine
  let ix = [(i,j) | i <- [0..h-1], j <- [0..w-1]]
  return $ array ((0,0),(h,w)) $ zip ix (concat tiles)

searchGoal :: SearchAction Position
searchGoal = do
  goal <- checkGoal
  if goal then returnPosition
          else do
            move
            searchGoal

checkGoal :: SearchAction Bool
checkGoal = do
  (f, vf, pos) <- get
  if f ! pos == '.' then return True
                    else do
                      loop <- lift $ readArray vf pos
                      if loop then put (f,vf,(-1,-1)) >> return True
                              else return False

returnPosition :: SearchAction Position
returnPosition = get >>= \(f,vf,pos) -> return pos


move :: SearchAction ()
move = do
  (f,vf,pos) <- get
  case f ! pos of
       '^' -> goUp
       'v' -> goDown
       '>' -> goRight
       '<' -> goLeft

goUp :: SearchAction ()
[goUp,goDown,goRight,goLeft] = map goAction [up,down,right,left]

goAction :: (Position -> Position) -> SearchAction ()
goAction func = do
  (f, vf, pos) <- get
  lift $ writeArray vf pos True
  put (f, vf, func pos)

up :: (Int,Int) -> (Int,Int)
up    (x,y) = (x-1, y)
down  (x,y) = (x+1, y)
right (x,y) = (x, y+1)
left  (x,y) = (x, y-1)