Language: C

#define M 26
P[M],A[M],B[M];
int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
	for(k=0;k<M;k++)A[k]=B[k]=0,P[k]=k;
	for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
	for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
}exit(0);}

Compiler output:
main.c:2:1: warning: data definition has no type or storage class
    2 | P[M],A[M],B[M];
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'P' [-Wimplicit-int]
main.c:2:6: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
    2 | P[M],A[M],B[M];
      |      ^
main.c:2:11: error: type defaults to 'int' in declaration of 'B' [-Wimplicit-int]
    2 | P[M],A[M],B[M];
      |           ^
main.c: In function 'R':
main.c:3:5: error: type of 'a' defaults to 'int' [-Wimplicit-int]
    3 | int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
      |     ^
main.c: At top level:
main.c:4:12: error: return type defaults to 'int' [-Wimplicit-int]
    4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
      |            ^~~~
main.c: In function 'main':
main.c:4:12: error: type of 'k' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:4:31: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
      |                               ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define M 26
main.c:4:31: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
      |                               ^~~~~
main.c:4:31: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:4:48: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
    4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
      |                                                ^~~~
main.c:4:48: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:6:51: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
    6 |         for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
      |                                                   ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen'
  +++ |+#include <string.h>
    1 | #define M 26
main.c:6:51: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
    6 |         for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
      |                                                   ^~~~~~
main.c:6:51: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:7:13: error: 'd' undeclared (first use in this function)
    7 |         for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
      |             ^
main.c:7:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:31: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
    7 |         for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
      |                               ^~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
  +++ |+#include <stdlib.h>
    1 | #define M 26
main.c:8:2: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
    8 | }exit(0);}
      |  ^~~~
main.c:8:2: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:8:2: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
main.c:8:2: note: include '<stdlib.h>' or provide a declaration of 'exit'