public void solve() throws IOException {
    char[][] board = new char[10][];
    for (int i = 0; i < 10; i++) {
      board[i] = nextLine().toCharArray();
    }
    
    List<Dir> path = new ArrayList<Dir>();
    
    Position start = getPosition(board, 's');
    for (int i = 0; i < 5; i++) {
      Position target = getPosition(board, (char)('1' + i));
      path.addAll(aStar(board, start, target, false));
      start = target;
    }
    path.addAll(aStar(board, start, getPosition(board, 'x'), true));
    
    for (Dir dir : path) {
      char output = ' ';
      switch (dir) {
      case LEFT: output = 'l'; break;
      case RIGHT: output = 'r'; break;
      case UP: output = 'u'; break;
      case DOWN: output = 'd'; break;
      }
      System.out.println(output);
    }
  }