uint@N,@K,c[5]{0,1,3,7,15},S[N]{},a=0,r;rep[S](s,N){string@T;rep(k,K)(s<<=4)|=c[T[k]-48];}sort(S,S+N);rep[S,i](s,N){r=0;rep(j,i+1,N)r|=(s&S[j])==s;a+=r;}wt(a);