var d = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

while (d[0] !== '0 0') {
  var footprints = {};
  var hw = d.shift().split(' ');
  var x = y = 0;
  var xy = '';

  var map = [];
  for (var i = 0; i < hw[0]; i++) map.push(d.shift().split(''));

  while (!((xy = x+' '+y) in footprints) && map[y][x] !== '.') {
    footprints[xy] = null;
    switch(map[y][x]) {
      case '^': y--; break;
      case '>': x++; break;
      case 'v': y++; break;
      case '<': x--; break;
    }
  }

  console.log(map[y][x] === '.' ? xy : 'LOOP');
}