<|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.

428. Rebus
Time limit per test: 0.5 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard



An addition rebus is a puzzle where you get an addition equation, like ABC+CBA=BDB, and you're asked to replace each letter with a digit (from 0 through 9) in such a way that:
Equal letters are replaced with equal digits.
Different letters are replaced with different digits.
None of the resulting numbers starts with 0, unless the entire number is just 0.
The resulting equation holds.


A proper addition rebus is an addition rebus with exactly one solution. An aligned addition rebus is an addition rebus where all three involved numbers have the same length (number of digits). The above addition rebus is aligned, but isn't proper: 143+341=484 and 341+143=484 are its two possible different solutions (and there are more).

Find 1000 different proper aligned addition rebuses. Two rebuses are different if there is no one-to-one mapping from the set of 26 English letters on itself that transfers one of those rebuses into another. For example, ABC+CBA=BDB and XAY+YAX=AZA are not different, while ABC+CBA=BDB and ABC+DEF=GHI are different.

Input
The input file will be empty.

Output
Output any 1000 different proper aligned addition rebuses, one per line. Each rebus may only use capital English letters, symbols '+' and '='. Each rebus must be at most 100 characters long.

Example(s)
Note that this example output doesn't contain the required 1000 rebuses, it contains just two.

sample input
sample output

AABC+AABB=DBCB
RRR+TTR=EDT

<|response|>
1) Abridged problem statement
- Print any 1000 different aligned addition rebuses (strings of the form L+R=S with L, R, S having equal length), each having exactly one solution when letters are replaced by distinct digits 0–9, with no leading zeros unless the number is zero.
- Two rebuses are considered the same if one can be transformed into the other by a bijection relabeling the letters.
- Each line must be at most 100 characters.
- The input is empty; just output the 1000 lines.

2) Key observations
- If we can force the unique digit assignment A=1, B=2, …, I=9, then the rebus has exactly one solution and no carries occur anywhere (all column sums ≤ 9).
- We can enforce that with columns of two kinds:
  - Buffer columns: A + A = B. The leftmost such column has no incoming carry, so 2·A < 10 ⇒ A ≤ 4 and B = 2·A.
  - Constraint columns: A + X = X+1 for X ∈ {A,…,H}.
- Many repeated buffer columns imply no carries can flow:
  - The leftmost buffer has no incoming carry ⇒ B = 2·A.
  - If any constraint column produced a carry-out, the adjacent buffer to its left would receive an incoming carry and force B = 2·A + 1 there, contradicting B = 2·A. Hence no constraint produces a carry, and therefore no buffer receives a carry. Thus there are no carries anywhere.
- With no carries, each constraint A + X = X+1 gives val(X+1) = val(A) + val(X), so val(B)=2·val(A), val(C)=3·val(A), …, val(I)=9·val(A). Distinct digits and the ≤ 9 bound force val(A)=1 and then B=2,…,I=9. This shows uniqueness (properness).
- To produce 1000 pairwise different (non-isomorphic) rebuses, permute the order of the eight constraints A+X=X+1 over X ∈ {A,…,H}. Different permutations yield strings not relatable by any letter bijection:
  - The pattern fixes A (it occupies all positions in the left addend) and then B (it's the result of A+A across all buffer columns).
  - The successor relations force any relabeling to preserve X → X+1 on A..I; with A and B fixed, that makes the relabeling identity on A..I. Therefore the order of constraints (the permutation) cannot be changed by relabeling, so all generated lines are pairwise different.
- Each number has 16 digits; a line is 16+1+16+1+16 = 50 characters ≤ 100.

3) Full solution approach
- Fix a permutation perm of the 8 letters A..H (there are 8! > 1000 choices). Iterate over 1000 different permutations.
- For each permutation, build three 16-letter strings L, R, S by concatenating 8 pairs of columns:
  - Buffer column: append A to L and R, append B to S (encodes A + A = B).
  - Constraint column: append A to L, perm[i] to R, and next(perm[i]) to S (encodes A + X = X+1).
- Output L + "+" + R + "=" + S for each permutation.
- Correctness:
  - The construction is aligned by design (all have length 16).
  - Leftmost buffer gives B=2·A and ensures A≤4. Repeated buffers prevent any incoming carry anywhere ⇒ no carries at all.
  - Then constraints enforce val(X)=k·val(A) for k=1..9, forcing A=1 and uniquely fixing B..I.
  - No number starts with 0 (leftmost digits are A, A, B, i.e., 1, 1, 2).
  - Different permutations yield pairwise non-isomorphic rebuses.
- Complexity: O(1000) generation and printing; trivial within limits.

4) C++ implementation

```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

void solve() {
    // The hard part in the problem is the uniqueness of the rebus solution.
    // However, this can be done by forcing one of the two numbers to be unique.
    // Let's take AA..AA, and assume that A will be mapped to 1. Then to
    // guarantee uniqueness, we also need to make sure the digits to letters are
    // not permutable. This can be done by making an ordering. In particular, we
    // want to use at least 9-1=8 different letters and add a condition of the
    // type A < B. This can be forced by having some digits where l[i] = A, r[i]
    // = letter, and result[i] = next(letter). We have to be careful about
    // buffers, so to guarantee this we will make sure l[i-1] = r[i-1] = A, and
    // result[i-1] = B. To make this concrete, let's take A-I. A corresponds to
    // 1, B to 2, C to 3 and so on until I to 9. We now need to place the 8
    // constraints. We can essentially create a string of length 8*2=16, where
    // odd positions are enforcing the no carry requirement, while even will
    // enforce the unique order of the letters. Then it's enough to just permute
    // the order of constraints.

    string perm = "ABCDEFGH";

    for(int steps = 0; steps < 1000; steps++) {
        next_permutation(perm.begin(), perm.end());

        string l, r, result;
        for(int i = 0; i < 8; i++) {
            l.push_back('A');
            l.push_back('A');
            r.push_back('A');
            r.push_back(perm[i]);
            result.push_back('B');
            result.push_back(perm[i] + 1);
        }
        cout << l << "+" << r << "=" << result << endl;
    }
}

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

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

5) Python implementation

```python
import sys


def next_permutation(seq):
    i = len(seq) - 2
    while i >= 0 and seq[i] >= seq[i + 1]:
        i -= 1
    if i < 0:
        seq.reverse()
        return False

    j = len(seq) - 1
    while seq[j] <= seq[i]:
        j -= 1

    seq[i], seq[j] = seq[j], seq[i]
    seq[i + 1:] = reversed(seq[i + 1:])
    return True


def solve():
    perm = list("ABCDEFGH")
    out_lines = []

    for _ in range(1000):
        next_permutation(perm)

        L = []
        R = []
        S = []

        for i in range(8):
            # Buffer: A + A = B
            L.append('A')
            R.append('A')
            S.append('B')

            # Constraint: A + X = X+1
            X = perm[i]
            L.append('A')
            R.append(X)
            S.append(chr(ord(X) + 1))

        Ls = "".join(L)
        Rs = "".join(R)
        Ss = "".join(S)
        out_lines.append(f"{Ls}+{Rs}={Ss}")

    sys.stdout.write("\n".join(out_lines))


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