pushing given as starting node into queu
q . append ( str ) NEW_LINE visit . add ( str ) NEW_LINE while ( len ( q ) ) : NEW_LINE INDENT str = q [ 0 ] NEW_LINE q . pop ( ) NEW_LINE if ( isValidString ( str ) ) : NEW_LINE INDENT print ( str ) NEW_LINE DEDENT DEDENT