The movie "Wanted" is very wonderful. A killer will kill one people by the name appeared at the cloth which is weaved by the Fate Loom.
One day, the rule of the Fate Loom is changed:
The cloth wide N and long M. Each unit of the cloth represent one English letter.
So there are lots of strings - each row or each column is a string.
For example:
googl
baidu
tence
alibb
acmer
is a cloth, and its strings of each row are:
googl, baidu, tence, alibb, acmer
its strings of each column are:
gbtaa, oaelc, oinim, gdcbe, luebr
And there are some names of person who should be killed.
You have to pay attention to that each letter on each row or each column must be a part of a name, or that whole row or column will be ignored.
For example:
One line is 'googl' and names are 'goo' and 'gl', so it's valid.
But if the names are 'goo' and 'gle', the line 'googl' will be ignored because 'goo' and 'gle' can't spell out 'googl'.
You should write a program that can calculate out how many valid rows and columns on the cloth.
For each case, you should output the number of valid rows and columns.