#!/usr/bin/python

# I Am That I Am, copyright (c) 2013 Nick Montfort <nickm@nickm.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
#
# Updated 31 May 2018, changed "print" for Python 2 & 3 compatibility
# Updated 26 November 2018, substituted a shorter all-permissive license

def permutations(elements):
    if len(elements) == 0:
        yield elements
    else:
        for result in permutations(elements[1:]):
            for i in range(len(elements)):
                yield result[:i] + elements[0:1] + result[i:]

print(' '.join(list(permutations('AEIOU'))))
