1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 using namespace std;
5 int L[10][10];
6 int indegree[10];
7 int TopSort();
8 int main()
9 {
10 int i,j,t;
11 string cover[5][5];
12 for(i=0; i<3; i++)
13 {
14 for(j=0; j<3; j++)
15 {
16 cover[i][j]+=j+1+i*3+‘0‘;
17 cover[i][j+1]+=j+1+i*3+‘0‘;
18 cover[i+1][j]+=j+1+i*3+‘0‘;
19 cover[i+1][j+1]+=j+1+i*3+‘0‘;
20 }
21 }
22 /**
23 for(i=0; i<4; i++)
24 {
25 for(j=0; j<4; j++)
26 {
27 string::iterator y;
28 for (y=cover[i][j].begin(); y!=cover[i][j].end(); ++y)
29 {
30 cout<<*y;
31 }
32 cout<<" ";
33 }
34 cout<<endl;
35 }
36 */
37 string s;
38 while(cin>>s)
39 {
40 getchar();
41 if(s=="ENDOFINPUT") break;
42 memset(indegree,0,sizeof(indegree));
43 memset(L,0,sizeof(L));
44 for(i=0; i<4; i++)
45 {
46 for(j=0; j<4; j++)
47 {
48 char x;
49 scanf("%c",&x);
50 string::iterator y;
51 for (y=cover[i][j].begin(); y!=cover[i][j].end(); ++y)
52 {
53 if((*y)!=x&&L[x-‘0‘][(*y)-‘0‘]==0)
54 {
55 L[x-‘0‘][(*y)-‘0‘]=1;
56 indegree[(*y)-‘0‘]++;
57 }
58 }
59 getchar();
60 }
61 }
62 cin>>s;
63 getchar();
64 /**
65 for(i=1; i<10; i++)
66 {
67 cout<<i<<":";
68 for(j=0; j<10; j++)
69 {
70 if(L[i][j]==1)
71 cout<<j<<" ";
72 }
73 cout<<endl;
74 }
75 cout<<"indegree:";
76 for(i=1; i<10; i++) cout<<indegree[i]<<" ";
77 cout<<endl;
78 */
79 int flag=TopSort();
80 if(flag) cout<<"THESE WINDOWS ARE CLEAN"<<endl;
81 else cout<<"THESE WINDOWS ARE BROKEN"<<endl;
82 }
83 return 0;
84 }
85 int TopSort()
86 {
87 int i,j;
88 int n=9;
89 int sign=0;
90 while(n--)
91 {
92 sign=0;
93 for(i=1; i<10; i++)
94 {
95 if(indegree[i]==0) sign=i;
96 }
97 if(sign>0)
98 {
99 for(j=0; j<10; j++)
100 {
101 if(L[sign][j])
102 indegree[j]--;
103 }
104 indegree[sign]=-1;
105 }
106 else if(sign==0) return 0;
107 }
108 return 1;
109 }