;要素と"リストのリスト"を掛け合わせる関数
(define (e-l ele lislis)
  (if (null? lislis) '()
      (cons (cons ele (car lislis)) (e-l ele (cdr lislis)))))
 
;リストと"リストのリスト"を掛け合わせる関数
(define (multi-list listA listB)
  (if (null? listA) '()
      (append (e-l (car listA) listB) (multi-list (cdr listA) listB))))
 
;サブ用の関数
(define (p-list count base ans)
  (if (= count 0) ans
      (p-list (- count 1) base (multi-list base ans))))
 
(define (p-generate count list)
  (p-list count list '(())))

(define chars (list #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j))
(define (n-cut-list n list)
  (if (= n 0) '()
      (cons (car list) (n-cut-list (- n 1) (cdr list)))))

(define num (read))
(define chs (n-cut-list num chars))

(define (good-string? ch-ls)
  (if (or (null? ch-ls) (null? (cdr ch-ls))) #t
      (let ((first (char->integer (car ch-ls)))
            (second (char->integer (car (cdr ch-ls)))))
        (if (or (> first second) (< (+ first 1) second)) #f
            (good-string? (cdr ch-ls))))))

(define (ok-string? ch-ls) (and (good-string? ch-ls) (char=? (car ch-ls) #\a)))

(define (solve list)
  (if (null? list) "Finish"
      (let ((carls (car list)))
        (if (ok-string? carls) (begin (display (list->string carls)) (newline) (solve (cdr list)))
            (solve (cdr list))))))

(solve (p-generate num chs))
