The Philosopher Box
Difficulty: Hard

<p><em>n</em> philosophers were sitting at a table trying to find the key to open the 
box that unleashes all the secrets of the world .</p>
<p>Each philosopher has a part of the key but none of them knows the whole full
key to open the box .</p>
<p>Each of the philosophers write down their keys on a piece of paper and finally 
they send all the papers to a cryptographer .</p>
<p>After analaysing the papers , the cryptographer finds out that some of the letters
were smudged so he may not be able to find out key to the box.</p>
<p>
If no letters were smudged in any of the paper , then he surely knows that if there is a 
key to the box then it must be a part of all the papers that he recieved .
</p>
<p>If some letters were smudged and still he is able to find out some common part in all
of the papers then he is sure that it must be the key but if he is not able to find out 
any common key then he says that '<em>Maybe</em>' there is a key to the box but it needs futher investigation.</p>
<p>
You are given the number of philosophers <em>n</em> , all the contents of the paper and if there is any letter in a paper that was smudged then that letter is denoted by '<em>?</em>'
</p>
<p><strong>Input Format</p></strong>
<p>First line contains '<em>n</em>' i.e. the number of philosophers.</p>
<p>The next <em>n</em> lines contain a string i.e. the key that each philosopher wrote on the paper</p>

<p><strong>Output Format</p></strong>

<p>'<em>Yes</em>' or '<em>No</em>' or '<em>Maybe</em>'</p>

<p><strong>Contraints</p></strong>
<p> 1 &lt <em>n</em> &lt 50000
<br>
Length of key given by each philosopher is less than 100
<br>
Key only only contains letter from '<em>a</em>' to '<em>z</em>' and '<em>?</em>'
</p>

<p><strong>Examples</p></strong>

<p><strong>Sample Input 1</p></strong>
<pre>
<code>
3
abc
def
ab?
</code>
</pre>
<p><strong>Sample Output 1</p></strong>
<pre>
<code>
No
</code>
</pre>
<p><strong>Explanation</p></strong>

<p>The first two strings has no common key so , the answer is '<em>No</em>'</p>

<p><strong>Sample Input 2</p></strong>
<pre>
<code>
2
abc
de?
</code>
</pre>
<p><strong>Sample Output 2</p></strong>
<pre>
<code>
Maybe
</code>
</pre>
<p><strong>Explanation</p></strong>

<p>The smudged letter might be '<em>a</em>' or '<em>b</em>' or '<em>c</em>' so answer is '<em>Maybe</em>'</p>

<p><strong>Sample Input 2</p></strong>
<pre>
<code>
3
abc
dc
ac
</code>
</pre>
<p><strong>Sample Output 2</p></strong>
<pre>
<code>
Yes
</code>
</pre>
<p><strong>Explanation:</p></strong>

<p>All the strings have '<em>c</em>' in common so answer is '<em>Yes</em>'</p>




Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (Python):
    import sys
    tt="qwertyuiopasdfghjklzxcvbnm?" #all accepted characters
    tt=list(tt)
    t=int(raw_input())
    seta=set() #Set A contains intersection of all strings without '?'
    setb=set() #Set B contains intersection of all strings with '?'
    seta_i=False  #Flag to check if there is atleast a single string without '?'
    setb_i=False  #Flag to check if there is atleast a single string with '?'

    for i in xrange(t):
        pp=str(raw_input()).strip()
        st=set(pp) #get only distinct characters from input string
        if '?' in st: #if string contains '?'
            if setb_i==False:
                setb_i=True
                setb=st
            else:
                setb=setb & st #Intersection with previous result 
        else: #if string doesn't contains '?'
            if seta_i==False:
                seta_i=True
                seta=st
            else:
                seta=seta & st #Intersection with previous result 

    if seta_i: # There is atleast one string without '?'
        if len(seta)==0: # If intersection of all strings without '?' is none then answer is 'No' 
            print 'No'
        else: #If there is some common elements in all strings without '?'
            if len(setb)==0: #And no strings with '?' , So answer is 'No'
                print 'Yes'
            elif len(seta & setb)>0: # If both Sets have something common answer is 'Yes' 
                print 'Yes'
            else: #If nothing common in both the sets then answer is 'Maybe'
                print 'Maybe'
    else: #If there were no strings without '?'
        if len(setb)==0: #not a necessary condition it would mean that there were no strings 
            print 'No'
        elif len(setb)>1: #If some part is common in strings with '?'
            print 'Yes'
        else: #if only '?' is common is all the strings
            print 'Maybe'