#include <cstdio>
#include <utility>
#include <vector>

using namespace std;

enum class Direction { North, East, South, West, Stop, Invalid };

Direction ToDirection(char sym) {
  switch (sym) {
    case '^':
      return Direction::North;
    case '>':
      return Direction::East;
    case 'v':
      return Direction::South;
    case '<':
      return Direction::West;
    case '.':
      return Direction::Stop;
    default:
      return Direction::Invalid;
  }
}

int main() {
  while (true) {
    int h, w;
    scanf("%d %d", &h, &w);
    if (h == 0 && w == 0) { break; }

    vector<vector<bool>> visited(h);
    vector<vector<Direction>> map(h);
    for (int y = 0; y < h; ++y) {
      visited[y] = std::move(vector<bool>(w));
      map[y] = std::move(vector<Direction>(w));
      for (int x = 0; x < w; ++x) {
     REDO:
        Direction d = ToDirection(getchar());
        if (d == Direction::Invalid) { goto REDO; }
        map[y][x] = d;
      }
      getchar(); // Drops newline
    }
    typedef pair<int, int> Position;
    Position position(0, 0);
    Direction next_direction = map[0][0];
    while (next_direction != Direction::Stop) {
      if (visited[position.first][position.second]) {
        puts("LOOP");
        goto NEXT_DATA;
      }
      visited[position.first][position.second] = true;
      switch (next_direction) {
        case Direction::North:
          position.first -= 1;
          break;
        case Direction::East:
          position.second += 1;
          break;
        case Direction::South:
          position.first += 1;
          break;
        case Direction::West:
          position.second -= 1;
          break;
        case Direction::Stop:
          puts("not reached");
          break;
      }
      next_direction = map[position.first][position.second];
    }
    printf("%d %d\n", position.second, position.first);
 NEXT_DATA:
    ;
  }

  return 0;
}