1 /*
2 Problem:poj 2585
3 OJ: POJ
4 User: S.B.S.
5 Time: 0 ms
6 Memory: 700 kb
7 Length: 1991 b
8 */
9 #include<iostream>
10 #include<cstdio>
11 #include<cstring>
12 #include<cmath>
13 #include<algorithm>
14 #include<queue>
15 #include<cstdlib>
16 #include<iomanip>
17 #include<cassert>
18 #include<climits>
19 #include<vector>
20 #include<list>
21 #include<map>
22 #define maxn 10001
23 #define F(i,j,k) for(int i=j;i<k;i++)
24 #define M(a,b) memset(a,b,sizeof(a))
25 #define FF(i,j,k) for(int i=j;i>=k;i--)
26 #define inf 0x7fffffff
27 #define maxm 2016
28 #define mod 1000000007
29 //#define LOCAL
30 using namespace std;
31 int read(){
32 int x=0,f=1;char ch=getchar();
33 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
34 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
35 return x*f;
36 }
37 int n,m;
38 int sc[4][4];
39 string cr[4][4];
40 bool vis[10];
41 int in[10];
42 bool g[10][10];
43 int t;
44 string s;
45 inline void init()
46 {
47 F(i,0,4)F(j,0,4) cr[i][j].erase();
48 F(k,1,10){
49 int i=(k-1)/3;
50 int j=(k-1)%3;
51 cr[i][j]+=char(k+‘0‘);
52 cr[i][j+1]+=char(k+‘0‘);
53 cr[i+1][j]+=char(k+‘0‘);
54 cr[i+1][j+1]+=char(k+‘0‘);
55 }
56 }
57 inline void input()
58 {
59 int i,j;
60 M(vis,0);M(in,0);M(g,0);
61 t=0;
62 int k;
63 F(i,0,4)F(j,0,4){
64 cin>>k;
65 sc[i][j]=k;
66 if(!vis[k]) t++;
67 vis[k]=true;
68 }
69 }
70 inline void build()
71 {
72 int a,b;
73 F(i,0,4)F(j,0,4)F(k,0,cr[i][j].length())
74 {
75 if((!g[sc[i][j]][cr[i][j][k]-‘0‘])&&(sc[i][j]!=cr[i][j][k]-‘0‘))
76 {
77 g[sc[i][j]][cr[i][j][k]-‘0‘]=true;
78 in[cr[i][j][k]-‘0‘]++;
79 }
80 }
81 }
82 inline bool ok()
83 {
84 int i,j,k;
85 F(k,0,t){
86 i=1;
87 while(!vis[i]||(i<=9&&in[i]>0)) i++;
88 if(i>9) return false;
89 vis[i]=false;
90 F(j,1,10){
91 if(vis[j]&&g[i][j]) in[j]--;
92 }
93 }
94 return true;
95 }
96 int main()
97 {
98 std::ios::sync_with_stdio(false);//cout<<setiosflags(ios::fixed)<<setprecision(1)<<y;
99 #ifdef LOCAL
100 freopen("data.in","r",stdin);
101 freopen("data.out","w",stdout);
102 #endif
103 init();
104 while(cin>>s)
105 {
106 if(s=="ENDOFINPUT") break;
107 input();
108 build();
109 if(ok()) cout<<"THESE WINDOWS ARE CLEAN"<<endl;
110 else cout<<"THESE WINDOWS ARE BROKEN"<<endl;
111 cin>>s;
112 }
113 return 0;
114 }