/* Problem 2--Reflected Photons
   This I thought was the trickiest one of the bunch.  The strategy
   isn't difficult to envision, but you do have manipulate the photon
   accurately. */

import java.io.*;
import java.util.*;

public class prob2 {

 public static Scanner in=null;
 public static PrintWriter out=null;
 public static int r=0, c=0, cs=1;
 public static char[][] A = null;

 public static void main (String[] args) throws Exception {

  in = new Scanner (new File ("prob2.in"));
  out = new PrintWriter ("prob2.out");
  int cs=1;
  while (true) {
   r = in.nextInt();
   c = in.nextInt();
   if (r==0 && c==0) break;
   in.nextLine();
   A = new char[r][c]; // get input
   for (int i=0; i < r; i++)
    A[i] = in.nextLine().toCharArray();
   Process ();
  }
  in.close();
  out.close();
 }

 /* Process goes through and emulates the photon at each entry point. */
 public static void Process () {

  int numsq = 2*r+2*c;
  int dr=0, dc=0, initr=0, initc=0;
  boolean[] sq = new boolean[numsq];
  out.println ("Case "+(cs++));
  for (int i=1; i <= numsq; i++) {
   if (sq[i-1]) continue; // Have we used this entry point already?
   if (i <= c) {dr=1;dc=0;initr=-1;initc=i-1;} //convert entry point to
   else if (i <= r+c) {dr=0;dc=-1;initr=i-c-1;initc=c;} // grid location
   else if (i <= r+2*c) {dr=-1;dc=0;initr=r;initc=r+2*c-i;}
   else {dr=0;dc=1;initr=2*r+2*c-i;initc=-1;}
   while (true) {
    initr+=dr; initc+=dc; //advance through Hall
    if (initc==-1 || initc==c || initr==-1 || initr==r) break; //Exit
    if (A[initr][initc]=='/') {int t = -dr; dr = -dc; dc = t;}
    else if (A[initr][initc]=='\\') {int t = dr; dr = dc; dc = t;}
   }     // reflect off mirror
   int val=0;
   if (initr==-1) val = initc+1; // translate grid location to
   else if (initc==c) val = c+initr+1; // exit point
   else if (initr==r) val = 2*c+r-initc;
   else val = 2*c+2*r-initr;
   out.println (i+"<-->"+val);
   sq[val-1]=true;
  }
  out.println();
 }
}
