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).  
4. Sort pairs by A, then B.  
5. Output the size and the list.

Complexity  
Time O(N log N) for generating N pairs and sorting. Memory O(N) for storing pairs. N≤10000 fits comfortably.

3. C++ Solution with Line-by-Line Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

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

    int N;
    int A0, B0;
    // Read modulus N and the base pair (A0, B0)
    cin >> N >> A0 >> B0;

    vector<pair<int,int>> v;
    v.reserve(N);
    // For each multiplier k from 0 to N-1:
    for (int k = 0; k < N; ++k) {
        // Compute A = k*A0 mod N, B = k*B0 mod N
        int A = (int)((1LL * k * A0) % N);
        int B = (int)((1LL * k * B0) % N);
        v.emplace_back(A, B);
    }

    // Remove duplicates: sort then erase unique
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    // Output the count of distinct pairs
    cout << v.size() << "\n";
    // Output each pair in ascending order
    for (auto &p : v) {
        cout << p.first << " " << p.second << "\n";
    }

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