#!/usr/bin/python
"""Count the number of sequences of length k of n elements that are (a) increasing, (b) decreasing, or (c) all even."""
def sequences(S, k):
"""Return S^k"""
assert k == int(k)
assert k >= 0
if k == 0:
yield []
else:
for head in S:
for tail in sequences(S, k-1):
yield [head] + tail
def increasing(s):
for i in range(len(s) - 1):
if s[i] >= s[i+1]:
return False
return True
def decreasing(s):
for i in range(len(s) - 1):
if s[i] <= s[i+1]:
return False
return True
def even(s):
for i in s:
if i % 2 == 1:
return False
return True
if __name__ == '__main__':
import sys
n = int(sys.argv[1])
k = int(sys.argv[2])
for s in sequences([ x+1 for x in range(n) ], k):
if increasing(s) or decreasing(s) or even(s):
print s