Problem:
Almost Identical Programs

The programming contest named
Concours de Programmation Comtemporaine Interuniversitaire (CPCI)
has a judging system similar to that of ICPC;
contestants have to submit correct outputs for two different inputs
to be accepted as a correct solution.

Each of the submissions should include the program that generated
the output. A pair of submissions is judged to be a correct
solution when, in addition to the correctness of the outputs, they
include an identical program.

Many contestants, however, do not stop including a different version
of their programs in their second submissions, after modifying a
single string literal in their programs representing
the input file name, attempting to process different input.

The organizers of CPCI are exploring the possibility of showing a
special error message for such close submissions,
indicating contestants what's wrong with such submissions.

Your task is to detect such close submissions.

Input

The input consists of at most 100 datasets, each in the following format.

s1
s2

Each of s1 and s2 is
a string written in a line, with the length between 1 and 200, inclusive.
They are the first and the second submitted programs respectively.

A program consists of lowercase letters (a, b, ..., z), uppercase letters (A, B, ..., Z),
digits (0, 1, ..., 9), double quotes ("), and semicolons (;).
When double quotes occur in a program, there are always even number of them.

The end of the input is indicated by a line containing one '.' (period).

Output

For each dataset, print the judge result in a line.

If the given two programs are identical, print IDENTICAL.
If two programs differ with only one corresponding string literal, print CLOSE.
Otherwise, print DIFFERENT.

A string literal is a possibly empty sequence of characters between an
odd-numbered occurrence of a double quote and the next occurrence of
a double quote.

Sample Input

print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.

Output for the Sample Input

IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT

Solution in C (judge verdict: Time Limit Exceeded)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
  while (1){
    char str1[200],str2[200];
  enum{
      IDENTICAL,
      CLOSE,
      DIFFERENT
    };

    fgets(str1,sizeof(str1),stdin);

    char check_if_input_ends = str1[0];

    if (check_if_input_ends == '.'){
      return 0;
    }

    fgets(str2,sizeof(str2),stdin);
    
    int judged = 0;
    int quote_cnt_changed = 0,double_quote_cnt = 0;
    int program_difference = 0,file_name_difference = 0;
    int i = 0,j = 0;

    while (str1[i] != '\0' || str2[j] != '\0'){
      if(quote_cnt_changed == 1){
        while (str1[i] != '"'){
          i++;
        }
        while (str2[j] != '"'){
          j++;
        }
      }
      if (str1[i] == '"' || str2[j] == '"'){
        if (str1[i] == '"' && str2[j] == '"'){
        } else if (str1[i] != '"'){
          if (double_quote_cnt % 2 == 0){
            program_difference++;
          } else {
            file_name_difference++;
          }
          while (str1[i] != '"'){
            i++;
          }
        } else {
          if (double_quote_cnt % 2 == 0){
            program_difference++;
          } else {
            file_name_difference++;
          }
          while (str2[j] != '"'){
            j++;
          }
        }
        double_quote_cnt++;
        quote_cnt_changed = 0;
      }

      if (double_quote_cnt % 2 == 0){
        if (str1[i] != str2[j] || program_difference > 0){
          printf("%s\n","DIFFERENT");
          judged++;
          break;
        }
      } else {
        if (str1[i] != str2[j] && quote_cnt_changed == 0){
          file_name_difference++;
          quote_cnt_changed++;
        }
      }
      i++;
      j++;
    }

    if (judged > 0){
      continue;
    }

    switch (file_name_difference){
      case IDENTICAL:
        printf("%s\n","IDENTICAL");
        break;
      case CLOSE:
        printf("%s\n","CLOSE");
        break;
      default:
        printf("%s\n","DIFFERENT");
        break;
    }
  }
  return 0;
}