#include <bits/stdc++.h>
struct Fraction {
  long long p, q;
  static inline long long gcd(long long a, long long b) {
    while (b ^= a ^= b ^= a = a % b)
      ;
    return a;
  }
  inline void clear() { p = 0, q = 1; }
  inline Fraction& simplify() {
    long long x = gcd(p, q);
    if (x == 1) return *this;
    p /= x, q /= x;
    return *this;
  }
  inline Fraction() { clear(); }
  inline Fraction(long long a, long long b) {
    p = a, q = b;
    simplify();
  }
  inline Fraction(long long a) { p = a, q = 1; }
  inline Fraction operator*(const Fraction& rhs) const {
    return Fraction(p * rhs.p, q * rhs.q);
  }
  inline bool operator<(const Fraction& rhs) const {
    return p * rhs.q < rhs.p * q;
  }
  inline bool operator==(const Fraction& rhs) const {
    return p * rhs.q == rhs.p * q;
  }
} ns[200200];
int n;
int hash[10000000];
inline long long read() {
  long long x = 0;
  static char c;
  while (c = getchar(), !isdigit(c))
    ;
  x = c - '0';
  while (c = getchar(), isdigit(c)) x = x * 10 + c - '0';
  return x;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int a = read(), b = read(), c = read();
    ns[i] = Fraction(a + b, c);
    ++hash[ns[i].p * 1000 + ns[i].q];
  }
  for (int i = 1; i <= n; ++i) printf("%d ", hash[ns[i].p * 1000 + ns[i].q]);
}
