<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

510. Distinct Substrings
Time limit per test: 0.25 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard

A well-known application of suffix trees is solving the following problem: given a string, find the number of distinct substrings that the string has. For example, the string "abac" has 9 distinct substrings: "a", "b", "c", "ab", "ba", "ac", "aba", "bac", "abac".

You are faced with generating testcases for this problem.

More specifically, you should find the shortest string consisting only of lowercase English letters that has exactly the given amount n of distinct substrings. Among several shortest strings, choose the lexicographically smallest one.

Input
First and only line of the input file contains an integer n, 1 ≤ n ≤ 300.

Output
In the only line of the output file write the sought string.

Example(s)
sample input
sample output
5
aab

<|response|>
## 1) Abridged problem statement (concise)

Given an integer \(n\) (\(1 \le n \le 300\)), output a string over lowercase English letters that has **exactly \(n\) distinct substrings**.  
Among all such strings, choose the **shortest**; if multiple, choose the **lexicographically smallest**.

---

## 2) Key observations needed to solve the problem

### Observation A — Distinct substrings can be counted via Suffix Automaton (SAM)
For a string \(s\), build its suffix automaton. For each state \(v\):

- `len[v]` = maximum length of substrings represented by state \(v\)
- `link[v]` = suffix link of \(v\)

Then the number of distinct substrings is:

\[
\#\text{distinct substrings} = \sum_{v \ne 0} \bigl(len[v] - len[link[v]]\bigr)
\]

Each SAM state corresponds to an equivalence class of substrings whose lengths form the interval  
\((len[link[v]]+1) \ldots len[v]\), hence it contributes exactly `len[v] - len[link[v]]` new substrings.

### Observation B — The constraints are tiny, but the time limit is extremely tight
Although \(n \le 300\) is small, the time limit (0.25s) is so strict that doing a nontrivial search online can be risky in some languages/environments.

A robust approach is therefore:

- **Offline precompute** the optimal answer for every \(n \le 300\).
- **Hardcode a lookup table** and print the precomputed string.

This makes runtime \(O(1)\).

### Observation C — How the precomputation can be done (conceptually)
To generate the table offline, you can do a DP/BFS-like relaxation:

- Maintain `best[k]` = best (shortest, then lexicographically smallest) string with exactly \(k\) distinct substrings found so far.
- From known `best[cnt]`, generate new candidates by inserting one character at any position.
- Use SAM as an oracle to compute `new_cnt = distinct_substrings(candidate)`.
- Relax `best[new_cnt]` with the optimization criteria.

This is essentially exploring strings by “one edit (insertion)” steps while classifying them by their distinct-substring counts.

---

## 3) Full solution approach based on the observations

Because of the strict time limit, the final accepted solution uses:

### Step 1 — Precomputed answers
Prepare an array `prec[0..300]` where `prec[n]` is the optimal string for that `n` (shortest, then lexicographically smallest) known to have exactly `n` distinct substrings.

This array is produced offline (using the SAM-based search described above) and then embedded directly into the program.

### Step 2 — Answer queries in constant time
- Read `n`
- Print `prec[n]`

That’s it: no suffix automaton is built during the actual run.

---

## 4) C++ implementation with detailed comments

```cpp
#include <bits/stdc++.h>
using namespace std;

/*
  This problem has a very strict time limit (0.25s).
  The intended fast approach is to precompute the optimal answer string
  for every n in [1..300] offline, then simply output prec[n].

  The array below is exactly such a precomputed table.
*/

static const vector<string> prec = {
    "",
    "a",
    "aa",
    "ab",
    "aaaa",
    "aab",
    "abc",
    "aaab",
    "aaba",
    "aabc",
    "abcd",
    "aaaba",
    "aaabc",
    "aabac",
    "aabcd",
    "abcde",
    "aaabba",
    "aaabac",
    "aaabcd",
    "aabacd",
    "aabcde",
    "abcdef",
    "aaaabcd",
    "aaabaca",
    "aaabacd",
    "aaabcde",
    "aabacde",
    "aabcdef",
    "abcdefg",
    "aaaabacd",
    "aaaabcde",
    "aaabacad",
    "aaabacde",
    "aaabcdef",
    "aabacdef",
    "aabcdefg",
    "abcdefgh",
    "aaaabacad",
    "aaaabacde",
    "aaaabcdef",
    "aaabacade",
    "aaabacdef",
    "aaabcdefg",
    "aabacdefg",
    "aabcdefgh",
    "abcdefghi",
    "aaaabaacde",
    "aaaabacade",
    "aaaabacdef",
    "aaaabcdefg",
    "aaabacadef",
    "aaabacdefg",
    "aaabcdefgh",
    "aabacdefgh",
    "aabcdefghi",
    "abcdefghij",
    "aaaaabcdefg",
    "aaaabaacdef",
    "aaaabacadef",
    "aaaabacdefg",
    "aaaabcdefgh",
    "aaabacadefg",
    "aaabacdefgh",
    "aaabcdefghi",
    "aabacdefghi",
    "aabcdefghij",
    "abcdefghijk",
    "aaaaabacdefg",
    "aaaaabcdefgh",
    "aaaabaacdefg",
    "aaaabacadefg",
    "aaaabacdefgh",
    "aaaabcdefghi",
    "aaabacadefgh",
    "aaabacdefghi",
    "aaabcdefghij",
    "aabacdefghij",
    "aabcdefghijk",
    "abcdefghijkl",
    "aaaaabacadefg",
    "aaaaabacdefgh",
    "aaaaabcdefghi",
    "aaaabaacdefgh",
    "aaaabacadefgh",
    "aaaabacdefghi",
    "aaaabcdefghij",
    "aaabacadefghi",
    "aaabacdefghij",
    "aaabcdefghijk",
    "aabacdefghijk",
    "aabcdefghijkl",
    "abcdefghijklm",
    "aaaaabaacdefgh",
    "aaaaabacadefgh",
    "aaaaabacdefghi",
    "aaaaabcdefghij",
    "aaaabaacdefghi",
    "aaaabacadefghi",
    "aaaabacdefghij",
    "aaaabcdefghijk",
    "aaabacadefghij",
    "aaabacdefghijk",
    "aaabcdefghijkl",
    "aabacdefghijkl",
    "aabcdefghijklm",
    "abcdefghijklmn",
    "aaaaabaacadefgh",
    "aaaaabaacdefghi",
    "aaaaabacadefghi",
    "aaaaabacdefghij",
    "aaaaabcdefghijk",
    "aaaabaacdefghij",
    "aaaabacadefghij",
    "aaaabacdefghijk",
    "aaaabcdefghijkl",
    "aaabacadefghijk",
    "aaabacdefghijkl",
    "aaabcdefghijklm",
    "aabacdefghijklm",
    "aabcdefghijklmn",
    "abcdefghijklmno",
    "aaaaaabcdefghijk",
    "aaaaabaacadefghi",
    "aaaaabaacdefghij",
    "aaaaabacadefghij",
    "aaaaabacdefghijk",
    "aaaaabcdefghijkl",
    "aaaabaacdefghijk",
    "aaaabacadefghijk",
    "aaaabacdefghijkl",
    "aaaabcdefghijklm",
    "aaabacadefghijkl",
    "aaabacdefghijklm",
    "aaabcdefghijklmn",
    "aabacdefghijklmn",
    "aabcdefghijklmno",
    "abcdefghijklmnop",
    "aaaaaabacdefghijk",
    "aaaaaabcdefghijkl",
    "aaaaabaacadefghij",
    "aaaaabaacdefghijk",
    "aaaaabacadefghijk",
    "aaaaabacdefghijkl",
    "aaaaabcdefghijklm",
    "aaaabaacdefghijkl",
    "aaaabacadefghijkl",
    "aaaabacdefghijklm",
    "aaaabcdefghijklmn",
    "aaabacadefghijklm",
    "aaabacdefghijklmn",
    "aaabcdefghijklmno",
    "aabacdefghijklmno",
    "aabcdefghijklmnop",
    "abcdefghijklmnopq",
    "aaaaaabacadefghijk",
    "aaaaaabacdefghijkl",
    "aaaaaabcdefghijklm",
    "aaaaabaacadefghijk",
    "aaaaabaacdefghijkl",
    "aaaaabacadefghijkl",
    "aaaaabacdefghijklm",
    "aaaaabcdefghijklmn",
    "aaaabaacdefghijklm",
    "aaaabacadefghijklm",
    "aaaabacdefghijklmn",
    "aaaabcdefghijklmno",
    "aaabacadefghijklmn",
    "aaabacdefghijklmno",
    "aaabcdefghijklmnop",
    "aabacdefghijklmnop",
    "aabcdefghijklmnopq",
    "abcdefghijklmnopqr",
    "aaaaaabaacdefghijkl",
    "aaaaaabacadefghijkl",
    "aaaaaabacdefghijklm",
    "aaaaaabcdefghijklmn",
    "aaaaabaacadefghijkl",
    "aaaaabaacdefghijklm",
    "aaaaabacadefghijklm",
    "aaaaabacdefghijklmn",
    "aaaaabcdefghijklmno",
    "aaaabaacdefghijklmn",
    "aaaabacadefghijklmn",
    "aaaabacdefghijklmno",
    "aaaabcdefghijklmnop",
    "aaabacadefghijklmno",
    "aaabacdefghijklmnop",
    "aaabcdefghijklmnopq",
    "aabacdefghijklmnopq",
    "aabcdefghijklmnopqr",
    "abcdefghijklmnopqrs",
    "aaaaaabaacadefghijkl",
    "aaaaaabaacdefghijklm",
    "aaaaaabacadefghijklm",
    "aaaaaabacdefghijklmn",
    "aaaaaabcdefghijklmno",
    "aaaaabaacadefghijklm",
    "aaaaabaacdefghijklmn",
    "aaaaabacadefghijklmn",
    "aaaaabacdefghijklmno",
    "aaaaabcdefghijklmnop",
    "aaaabaacdefghijklmno",
    "aaaabacadefghijklmno",
    "aaaabacdefghijklmnop",
    "aaaabcdefghijklmnopq",
    "aaabacadefghijklmnop",
    "aaabacdefghijklmnopq",
    "aaabcdefghijklmnopqr",
    "aabacdefghijklmnopqr",
    "aabcdefghijklmnopqrs",
    "abcdefghijklmnopqrst",
    "aaaaaabaacadaefghijkl",
    "aaaaaabaacadefghijklm",
    "aaaaaabaacdefghijklmn",
    "aaaaaabacadefghijklmn",
    "aaaaaabacdefghijklmno",
    "aaaaaabcdefghijklmnop",
    "aaaaabaacadefghijklmn",
    "aaaaabaacdefghijklmno",
    "aaaaabacadefghijklmno",
    "aaaaabacdefghijklmnop",
    "aaaaabcdefghijklmnopq",
    "aaaabaacdefghijklmnop",
    "aaaabacadefghijklmnop",
    "aaaabacdefghijklmnopq",
    "aaaabcdefghijklmnopqr",
    "aaabacadefghijklmnopq",
    "aaabacdefghijklmnopqr",
    "aaabcdefghijklmnopqrs",
    "aabacdefghijklmnopqrs",
    "aabcdefghijklmnopqrst",
    "abcdefghijklmnopqrstu",
    "aaaaaaabcdefghijklmnop",
    "aaaaaabaacadaefghijklm",
    "aaaaaabaacadefghijklmn",
    "aaaaaabaacdefghijklmno",
    "aaaaaabacadefghijklmno",
    "aaaaaabacdefghijklmnop",
    "aaaaaabcdefghijklmnopq",
    "aaaaabaacadefghijklmno",
    "aaaaabaacdefghijklmnop",
    "aaaaabacadefghijklmnop",
    "aaaaabacdefghijklmnopq",
    "aaaaabcdefghijklmnopqr",
    "aaaabaacdefghijklmnopq",
    "aaaabacadefghijklmnopq",
    "aaaabacdefghijklmnopqr",
    "aaaabcdefghijklmnopqrs",
    "aaabacadefghijklmnopqr",
    "aaabacdefghijklmnopqrs",
    "aaabcdefghijklmnopqrst",
    "aabacdefghijklmnopqrst",
    "aabcdefghijklmnopqrstu",
    "abcdefghijklmnopqrstuv",
    "aaaaaaabacdefghijklmnop",
    "aaaaaaabcdefghijklmnopq",
    "aaaaaabaacadaefghijklmn",
    "aaaaaabaacadefghijklmno",
    "aaaaaabaacdefghijklmnop",
    "aaaaaabacadefghijklmnop",
    "aaaaaabacdefghijklmnopq",
    "aaaaaabcdefghijklmnopqr",
    "aaaaabaacadefghijklmnop",
    "aaaaabaacdefghijklmnopq",
    "aaaaabacadefghijklmnopq",
    "aaaaabacdefghijklmnopqr",
    "aaaaabcdefghijklmnopqrs",
    "aaaabaacdefghijklmnopqr",
    "aaaabacadefghijklmnopqr",
    "aaaabacdefghijklmnopqrs",
    "aaaabcdefghijklmnopqrst",
    "aaabacadefghijklmnopqrs",
    "aaabacdefghijklmnopqrst",
    "aaabcdefghijklmnopqrstu",
    "aabacdefghijklmnopqrstu",
    "aabcdefghijklmnopqrstuv",
    "abcdefghijklmnopqrstuvw",
    "aaaaaaabacadefghijklmnop",
    "aaaaaaabacdefghijklmnopq",
    "aaaaaaabcdefghijklmnopqr",
    "aaaaaabaacadaefghijklmno",
    "aaaaaabaacadefghijklmnop",
    "aaaaaabaacdefghijklmnopq",
    "aaaaaabacadefghijklmnopq",
    "aaaaaabacdefghijklmnopqr",
    "aaaaaabcdefghijklmnopqrs",
    "aaaaabaacadefghijklmnopq",
    "aaaaabaacdefghijklmnopqr",
    "aaaaabacadefghijklmnopqr",
    "aaaaabacdefghijklmnopqrs",
    "aaaaabcdefghijklmnopqrst",
    "aaaabaacdefghijklmnopqrs",
    "aaaabacadefghijklmnopqrs",
    "aaaabacdefghijklmnopqrst",
    "aaaabcdefghijklmnopqrstu",
    "aaabacadefghijklmnopqrst",
    "aaabacdefghijklmnopqrstu",
    "aaabcdefghijklmnopqrstuv",
    "aabacdefghijklmnopqrstuv",
    "aabcdefghijklmnopqrstuvw",
    "abcdefghijklmnopqrstuvwx"
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    // Output the precomputed optimal string for this n.
    cout << prec[n] << "\n";
    return 0;
}
```

---

## 5) Python implementation with detailed comments

```python
import sys

"""
This problem has a very strict time limit (0.25s).
To guarantee speed, we use a precomputed lookup table PREC[n]
that contains the shortest and then lexicographically smallest
string with exactly n distinct substrings for all n <= 300.
"""

PREC = [
    "",
    "a",
    "aa",
    "ab",
    "aaaa",
    "aab",
    "abc",
    "aaab",
    "aaba",
    "aabc",
    "abcd",
    "aaaba",
    "aaabc",
    "aabac",
    "aabcd",
    "abcde",
    "aaabba",
    "aaabac",
    "aaabcd",
    "aabacd",
    "aabcde",
    "abcdef",
    "aaaabcd",
    "aaabaca",
    "aaabacd",
    "aaabcde",
    "aabacde",
    "aabcdef",
    "abcdefg",
    "aaaabacd",
    "aaaabcde",
    "aaabacad",
    "aaabacde",
    "aaabcdef",
    "aabacdef",
    "aabcdefg",
    "abcdefgh",
    "aaaabacad",
    "aaaabacde",
    "aaaabcdef",
    "aaabacade",
    "aaabacdef",
    "aaabcdefg",
    "aabacdefg",
    "aabcdefgh",
    "abcdefghi",
    "aaaabaacde",
    "aaaabacade",
    "aaaabacdef",
    "aaaabcdefg",
    "aaabacadef",
    "aaabacdefg",
    "aaabcdefgh",
    "aabacdefgh",
    "aabcdefghi",
    "abcdefghij",
    "aaaaabcdefg",
    "aaaabaacdef",
    "aaaabacadef",
    "aaaabacdefg",
    "aaaabcdefgh",
    "aaabacadefg",
    "aaabacdefgh",
    "aaabcdefghi",
    "aabacdefghi",
    "aabcdefghij",
    "abcdefghijk",
    "aaaaabacdefg",
    "aaaaabcdefgh",
    "aaaabaacdefg",
    "aaaabacadefg",
    "aaaabacdefgh",
    "aaaabcdefghi",
    "aaabacadefgh",
    "aaabacdefghi",
    "aaabcdefghij",
    "aabacdefghij",
    "aabcdefghijk",
    "abcdefghijkl",
    "aaaaabacadefg",
    "aaaaabacdefgh",
    "aaaaabcdefghi",
    "aaaabaacdefgh",
    "aaaabacadefgh",
    "aaaabacdefghi",
    "aaaabcdefghij",
    "aaabacadefghi",
    "aaabacdefghij",
    "aaabcdefghijk",
    "aabacdefghijk",
    "aabcdefghijkl",
    "abcdefghijklm",
    "aaaaabaacdefgh",
    "aaaaabacadefgh",
    "aaaaabacdefghi",
    "aaaaabcdefghij",
    "aaaabaacdefghi",
    "aaaabacadefghi",
    "aaaabacdefghij",
    "aaaabcdefghijk",
    "aaabacadefghij",
    "aaabacdefghijk",
    "aaabcdefghijkl",
    "aabacdefghijkl",
    "aabcdefghijklm",
    "abcdefghijklmn",
    "aaaaabaacadefgh",
    "aaaaabaacdefghi",
    "aaaaabacadefghi",
    "aaaaabacdefghij",
    "aaaaabcdefghijk",
    "aaaabaacdefghij",
    "aaaabacadefghij",
    "aaaabacdefghijk",
    "aaaabcdefghijkl",
    "aaabacadefghijk",
    "aaabacdefghijkl",
    "aaabcdefghijklm",
    "aabacdefghijklm",
    "aabcdefghijklmn",
    "abcdefghijklmno",
    "aaaaaabcdefghijk",
    "aaaaabaacadefghi",
    "aaaaabaacdefghij",
    "aaaaabacadefghij",
    "aaaaabacdefghijk",
    "aaaaabcdefghijkl",
    "aaaabaacdefghijk",
    "aaaabacadefghijk",
    "aaaabacdefghijkl",
    "aaaabcdefghijklm",
    "aaabacadefghijkl",
    "aaabacdefghijklm",
    "aaabcdefghijklmn",
    "aabacdefghijklmn",
    "aabcdefghijklmno",
    "abcdefghijklmnop",
    "aaaaaabacdefghijk",
    "aaaaaabcdefghijkl",
    "aaaaabaacadefghij",
    "aaaaabaacdefghijk",
    "aaaaabacadefghijk",
    "aaaaabacdefghijkl",
    "aaaaabcdefghijklm",
    "aaaabaacdefghijkl",
    "aaaabacadefghijkl",
    "aaaabacdefghijklm",
    "aaaabcdefghijklmn",
    "aaabacadefghijklm",
    "aaabacdefghijklmn",
    "aaabcdefghijklmno",
    "aabacdefghijklmno",
    "aabcdefghijklmnop",
    "abcdefghijklmnopq",
    "aaaaaabacadefghijk",
    "aaaaaabacdefghijkl",
    "aaaaaabcdefghijklm",
    "aaaaabaacadefghijk",
    "aaaaabaacdefghijkl",
    "aaaaabacadefghijkl",
    "aaaaabacdefghijklm",
    "aaaaabcdefghijklmn",
    "aaaabaacdefghijklm",
    "aaaabacadefghijklm",
    "aaaabacdefghijklmn",
    "aaaabcdefghijklmno",
    "aaabacadefghijklmn",
    "aaabacdefghijklmno",
    "aaabcdefghijklmnop",
    "aabacdefghijklmnop",
    "aabcdefghijklmnopq",
    "abcdefghijklmnopqr",
    "aaaaaabaacdefghijkl",
    "aaaaaabacadefghijkl",
    "aaaaaabacdefghijklm",
    "aaaaaabcdefghijklmn",
    "aaaaabaacadefghijkl",
    "aaaaabaacdefghijklm",
    "aaaaabacadefghijklm",
    "aaaaabacdefghijklmn",
    "aaaaabcdefghijklmno",
    "aaaabaacdefghijklmn",
    "aaaabacadefghijklmn",
    "aaaabacdefghijklmno",
    "aaaabcdefghijklmnop",
    "aaabacadefghijklmno",
    "aaabacdefghijklmnop",
    "aaabcdefghijklmnopq",
    "aabacdefghijklmnopq",
    "aabcdefghijklmnopqr",
    "abcdefghijklmnopqrs",
    "aaaaaabaacadefghijkl",
    "aaaaaabaacdefghijklm",
    "aaaaaabacadefghijklm",
    "aaaaaabacdefghijklmn",
    "aaaaaabcdefghijklmno",
    "aaaaabaacadefghijklm",
    "aaaaabaacdefghijklmn",
    "aaaaabacadefghijklmn",
    "aaaaabacdefghijklmno",
    "aaaaabcdefghijklmnop",
    "aaaabaacdefghijklmno",
    "aaaabacadefghijklmno",
    "aaaabacdefghijklmnop",
    "aaaabcdefghijklmnopq",
    "aaabacadefghijklmnop",
    "aaabacdefghijklmnopq",
    "aaabcdefghijklmnopqr",
    "aabacdefghijklmnopqr",
    "aabcdefghijklmnopqrs",
    "abcdefghijklmnopqrst",
    "aaaaaabaacadaefghijkl",
    "aaaaaabaacadefghijklm",
    "aaaaaabaacdefghijklmn",
    "aaaaaabacadefghijklmn",
    "aaaaaabacdefghijklmno",
    "aaaaaabcdefghijklmnop",
    "aaaaabaacadefghijklmn",
    "aaaaabaacdefghijklmno",
    "aaaaabacadefghijklmno",
    "aaaaabacdefghijklmnop",
    "aaaaabcdefghijklmnopq",
    "aaaabaacdefghijklmnop",
    "aaaabacadefghijklmnop",
    "aaaabacdefghijklmnopq",
    "aaaabcdefghijklmnopqr",
    "aaabacadefghijklmnopq",
    "aaabacdefghijklmnopqr",
    "aaabcdefghijklmnopqrs",
    "aabacdefghijklmnopqrs",
    "aabcdefghijklmnopqrst",
    "abcdefghijklmnopqrstu",
    "aaaaaaabcdefghijklmnop",
    "aaaaaabaacadaefghijklm",
    "aaaaaabaacadefghijklmn",
    "aaaaaabaacdefghijklmno",
    "aaaaaabacadefghijklmno",
    "aaaaaabacdefghijklmnop",
    "aaaaaabcdefghijklmnopq",
    "aaaaabaacadefghijklmno",
    "aaaaabaacdefghijklmnop",
    "aaaaabacadefghijklmnop",
    "aaaaabacdefghijklmnopq",
    "aaaaabcdefghijklmnopqr",
    "aaaabaacdefghijklmnopq",
    "aaaabacadefghijklmnopq",
    "aaaabacdefghijklmnopqr",
    "aaaabcdefghijklmnopqrs",
    "aaabacadefghijklmnopqr",
    "aaabacdefghijklmnopqrs",
    "aaabcdefghijklmnopqrst",
    "aabacdefghijklmnopqrst",
    "aabcdefghijklmnopqrstu",
    "abcdefghijklmnopqrstuv",
    "aaaaaaabacdefghijklmnop",
    "aaaaaaabcdefghijklmnopq",
    "aaaaaabaacadaefghijklmn",
    "aaaaaabaacadefghijklmno",
    "aaaaaabaacdefghijklmnop",
    "aaaaaabacadefghijklmnop",
    "aaaaaabacdefghijklmnopq",
    "aaaaaabcdefghijklmnopqr",
    "aaaaabaacadefghijklmnop",
    "aaaaabaacdefghijklmnopq",
    "aaaaabacadefghijklmnopq",
    "aaaaabacdefghijklmnopqr",
    "aaaaabcdefghijklmnopqrs",
    "aaaabaacdefghijklmnopqr",
    "aaaabacadefghijklmnopqr",
    "aaaabacdefghijklmnopqrs",
    "aaaabcdefghijklmnopqrst",
    "aaabacadefghijklmnopqrs",
    "aaabacdefghijklmnopqrst",
    "aaabcdefghijklmnopqrstu",
    "aabacdefghijklmnopqrstu",
    "aabcdefghijklmnopqrstuv",
    "abcdefghijklmnopqrstuvw",
    "aaaaaaabacadefghijklmnop",
    "aaaaaaabacdefghijklmnopq",
    "aaaaaaabcdefghijklmnopqr",
    "aaaaaabaacadaefghijklmno",
    "aaaaaabaacadefghijklmnop",
    "aaaaaabaacdefghijklmnopq",
    "aaaaaabacadefghijklmnopq",
    "aaaaaabacdefghijklmnopqr",
    "aaaaaabcdefghijklmnopqrs",
    "aaaaabaacadefghijklmnopq",
    "aaaaabaacdefghijklmnopqr",
    "aaaaabacadefghijklmnopqr",
    "aaaaabacdefghijklmnopqrs",
    "aaaaabcdefghijklmnopqrst",
    "aaaabaacdefghijklmnopqrs",
    "aaaabacadefghijklmnopqrs",
    "aaaabacdefghijklmnopqrst",
    "aaaabcdefghijklmnopqrstu",
    "aaabacadefghijklmnopqrst",
    "aaabacdefghijklmnopqrstu",
    "aaabcdefghijklmnopqrstuv",
    "aabacdefghijklmnopqrstuv",
    "aabcdefghijklmnopqrstuvw",
    "abcdefghijklmnopqrstuvwx",
]

def main() -> None:
    # Read single integer n
    data = sys.stdin.read().strip()
    n = int(data)

    # Print the precomputed optimal answer in O(1)
    sys.stdout.write(PREC[n] + "\n")

if __name__ == "__main__":
    main()
```

---

If you want, I can also include (as an extra section) the **offline generator** outline (SAM + insertion-based relaxation) that was used to build the table—useful for learning, but not needed in the final submission.