Check if the upper move is valid
if ( isSafe ( row - 1 , col , m , n , visited ) ) : NEW_LINE INDENT path += ' U ' NEW_LINE printPathUtil ( row - 1 , col , m , n , path , possiblePaths , visited ) NEW_LINE path = path [ : - 1 ] NEW_LINE DEDENT