Starring the unknowns

All submissions for this problem are available.
At BITS Pilani, Goa Campus there was a conference on coding and cryptography during Quark. The following theorem needed a proof or a counterexample: Suppose we are given a set of words of equal length; each word consisting of 0's, 1's and/or *'s. Also suppose that the pattern of *'s is different for all words in the set.
The claim is: if you the *'s are replaced by 0's and 1's in all possible ways, then you obtain a set that is at least as big as the set you started with initially.
Example:
{ 10*, *0*, *00 } produces { 100, 101, 000, 001 }
{ 100, 101, 10* } produces { 100, 101 }
Notice that the set in the latter example does not satisfy the condidtion mentioned above, so it does
not provide a counterexample.
Write a program which has to check for a number of cases:
1. Whether the pattern of *'s is different for all words in the set and:
2. Compute the number of words obtained by replacing the *'s by 0's and 1's.
The words will not be longer than 15 symbols(containing 0's,1's and *'s).
Input
The input is of the format of a textfile that represents a sequence of sets. Each set is described as follows. The first line
gives only two non negative integers: the length of the words and the number of the words. Then follow the words, one word
on a separate line. The end of the sequence of sets is indicated by a set with wordlength 0 and number of words equal to 0.
Output
The output is a textfile that has one line for each set. if the pattern of *'s is different for all the
words in this set this line should contain YES (in uppercase), followed by a space and the number of
obtained words, otherwise it should contain NO (uppercase) only.
Sample Input
3 3
10*
*0*
*00
Sample Output
YES 4
Author:  dhwanitquark 
Tags  dhwanitquark 
Date Added:  4022016 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 