#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<double, int> A, B;
  for (int i = 0; i < n; i++) {
    double a, b;
    cin >> a >> b;
    A[a / b]++;
    B[-b / a]++;
  }
  cout << "B\n";
  for (auto x : B) {
    cout << x.first << " " << x.second << "\n";
  }
  cout << "A\n";
  for (auto x : A) {
    cout << x.first << " " << x.second << "\n";
  }
  int cont = 0;
  for (auto x : A) {
    if (B[x.first] != 0) {
      cout << x.first << " " << x.second << ":\n";
      for (auto k : B) {
        if (k.first != B[x.second]) k.second--, cont++;
      }
    } else {
      for (auto k : B) {
        if (-k.first != x.first) cont++, k.second--;
      }
    }
  }
  cout << cont << "\n";
}
