#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(n: usize, cur: &mut Vec<usize>, end: usize) {
    if cur.len() == n {
        for &e in cur.iter() {
            print!("{:x}", e + 10);
        }
        println!("");
        return;
    }
    for i in 0..end {
        cur.push(i);
        dfs(n, cur, end);
        cur.pop();
    }
    cur.push(end);
    dfs(n, cur, end + 1);
    cur.pop();
}

fn main() {
    let n = read::<usize>();
    let mut cur = vec![0];
    dfs(n, &mut cur, 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
