1. Abridged Problem Statement
Given integers N, A₀, B₀ (0≤A₀,B₀<N), find all pairs (A,B) with 0≤A,B<N such that
 whenever A₀·X + B₀·Y ≡ 0 (mod N) for integers X,Y, it follows that A·X + B·Y ≡ 0 (mod N).
Output the count of such pairs, then list them in ascending order (by A, then B).

2. Detailed Editorial

Goal
We look for all linear forms A·X+B·Y that vanish modulo N on the same integer lattice points (X,Y) where the “original” form A₀·X+B₀·Y vanishes.

Key Observation
If A₀X+B₀Y ≡ 0 (mod N), then multiplying that congruence by any fixed integer k yields
 k·A₀X + k·B₀Y ≡ 0 (mod N).
Hence every pair (A,B) of the form
 A ≡ k·A₀ (mod N), B ≡ k·B₀ (mod N)
automatically satisfies the requirement.

Completeness
One must also argue no other pairs exist. Suppose (A,B) satisfies the condition. In particular, it must hold when (X,Y) ranges over all possible values. Over the ring ℤ/Nℤ, the set of zeros of the linear form A₀X+B₀Y is a one-dimensional subspace (a cyclic subgroup) of (ℤ/Nℤ)². A form A·X+B·Y that vanishes on that same subgroup must be a scalar multiple of A₀X+B₀Y in the quotient ring ℤ/Nℤ. In other words,
 (A,B) ≡ k·(A₀,B₀) (mod N)
for some k.

Algorithm
1. Read N, A₀, B₀.
2. For k from 0 to N−1 compute
 A = (k·A₀) mod N,
 B = (k·B₀) mod N.
3. Collect all unique pairs (A,B) (a set handles deduplication and ordering).
4. Output the size and the list, already sorted by A then B.

Complexity
Time O(N log N) for generating N pairs and inserting them into a set. Memory O(N) for storing pairs. N≤10000 fits comfortably.

3. C++ Solution
```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;
};

int n, a0, b0;

void read() { cin >> n >> a0 >> b0; }

void solve() {
    // The valid pairs (A, B) are exactly the integer multiples of (A0, B0)
    // taken modulo N: (k*A0 mod N, k*B0 mod N) for k = 0..N-1. Generate all of
    // them, deduplicate, and output sorted by A then B.

    set<pair<int, int>> pairs;
    for(int k = 0; k < n; k++) {
        pairs.insert({(int)((int64_t)k * a0 % n), (int)((int64_t)k * b0 % n)});
    }

    cout << pairs.size() << '\n';
    for(auto& p: pairs) {
        cout << p.first << ' ' << p.second << '\n';
    }
}

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

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

    return 0;
}
```

4. Python Solution with Detailed Comments
```python
def find_magic_pairs(N, A0, B0):
    # We'll store all candidate pairs (A, B) in a list
    pairs = []

    # Multiply the base pair by k = 0,1,...,N-1 modulo N
    for k in range(N):
        A = (k * A0) % N  # scalar multiply A0
        B = (k * B0) % N  # scalar multiply B0
        pairs.append((A, B))  # collect the result

    # Remove duplicates by converting to a set, then back to list
    pairs = list(set(pairs))
    # Sort by A first, then B
    pairs.sort()
    return pairs

def main():
    # Read input
    N = int(input().strip())
    A0, B0 = map(int, input().split())

    # Compute all valid pairs
    pairs = find_magic_pairs(N, A0, B0)

    # Print the number of pairs
    print(len(pairs))
    # Print each pair on its own line
    for A, B in pairs:
        print(A, B)

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

5. Compressed Editorial
All valid (A,B) are exactly the scalar multiples of (A₀,B₀) in the ring ℤ/Nℤ. Enumerate k=0…N−1, compute (k·A₀ mod N, k·B₀ mod N), deduplicate and sort. Time O(N log N).
