import java.util.List;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

class Diff {
  public static void main(String...args) throws IOException {
    Path path1 = Paths.get(args[0]);
    Path path2 = Paths.get(args[1]);
      List<String> lines1 = Files.readAllLines(path1);
      List<String> lines2 = Files.readAllLines(path2);
      int m = lines1.size();
      int n = lines2.size();

      //StringBuilder sb = new StringBuilder();

      // opt[i][j] = length of LCS of x[i..m] and y[j..n]
      int[][] opt = new int[m+1][n+1];

      // compute length of LCS and all subproblems via dynamic programming
      for(int i = m-1; i >= 0; --i) {
        for(int j = n-1; j >= 0; --j) {
          if(lines1.get(i).equals(lines2.get(j))) opt[i][j] = opt[i+1][j+1] + 1;
          else opt[i][j] = Math.max(opt[i+1][j], opt[i][j+1]);
        }
      }

      // recover LCS itself and print out non-matching lines to standard output
      int i = 0, j = 0;
      while(i < m && j < n) {
        if(opt[i][j] > opt[i][j+1] && opt[i][j] > opt[i+1][j]) {
          ++i;
          ++j;
        } else {
          int ii;
          int jj;
          for(ii = i; ii < m && opt[ii][j] == opt[ii+1][j]; ii++) {}
          for(jj = j; jj < n && opt[ii][jj] == opt[ii][jj+1]; jj++) {}
          char command = ii <= i ? 'a' : jj <= j ? 'd' : 'c';
          String left = i+1 >= ii ? "" + ii : (i+1) + "," + ii;
          String right = j+1 >= jj ? "" + jj : (j+1) + "," + jj;
          System.out.print(left + command + right + '\n');
          while(i < ii) {
            System.out.print("< " + lines1.get(i++) + '\n');
          }
          if(command == 'c') System.out.print("---" + '\n');
          while(j < jj) {
            System.out.print("> " + lines2.get(j++) + '\n');
          }
        }
      }

      // dump out one remainder of one string if the other is exhausted
      if(i < m || j < n) {
        char command = m <= i ? 'a' : n <= j ? 'd' : 'c';
        String left = i+1 >= m ? "" + m : (i+1) + "," + m;
        String right = j+1 >= n ? "" + n : (j+1) + "," + n;
        System.out.print(left + command + right + '\n');
        while(i < m) {
          System.out.print("< " + lines1.get(i++) + '\n');
        }
        if(command == 'c') System.out.print("---" + '\n');
        while(j < n) {
          System.out.print("> " + lines2.get(j++) + '\n');
        }
      }
      // EditWindow editWindow
      //   = new EditWindow(path1.fullName() + " <> " + path2.fullName(),
      //                    sb.toString());
      // editWindow.pack();
      // editWindow.setVisible(true);
      //} // public static void diff(MyPath path1, MyPath path2)
  }
}
