use proconio::input;
use std::char::from_u32;

fn rec(n: i32, used: i32, s: &mut Vec<char>, res: &mut Vec<String>) {
    if n == 0 {
        res.push(s.iter().rev().collect());
        return;
    }
    for i in 0..used {
        s[n as usize - 1] = from_u32(97 + i as u32).unwrap();
        rec(n - 1, used, s, res);
    }
    s[n as usize - 1] = from_u32(97 + used as u32).unwrap();
    rec(n - 1, used + 1, s, res);
}

fn solve(n: i32) -> Vec<String> {
    let mut res = Vec::new();
    let mut s = Vec::new();
    s.resize(n as usize, 'a');
    rec(n - 1, 1, &mut s, &mut res);
    res
}

fn main() {
    input! {
        n: i32,
    }
    let r = solve(n);
    for s in r {
        println!("{}", s);
    }
}
