#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <iostream>
#include <iomanip>

int main()
{
    using sequence_type = std::vector<std::string> ;
    sequence_type seq { "abc", "def", "abc", "ghi", "def", "abc" } ;
    std::sort( seq.begin(), seq.end() ) ;

    std::set<sequence_type> unique_permutations ;

    do unique_permutations.insert( sequence_type( seq.begin(), seq.end() ) ) ;
    while( std::next_permutation( seq.begin(), seq.end() ) ) ;

    for( const auto& seq : unique_permutations )
    {
        static int n = 0 ;
        std::cout << std::setw(3) << ++n << ". " ;
        for( const auto& str : seq ) std::cout << str << ' ' ;
        std::cout << '\n' ;
    }
}
