Sort the Fabrics

아직 제출이 없습니다시간 제한20초메모리 제한1024 MB

문제

A fabric is represented by three properties:

  • Color (C\mathbf{C}), a string consisting of lowercase letters of the English alphabet, representing the color of the fabric.
  • Durability (D\mathbf{D}), an integer representing the durability of the fabric.
  • Unique identifier (U\mathbf{U}), an integer representing the ID of the fabric.

Ada and Charles work at the Kick Start fabric factory. Each day they receive N\mathbf{N} fabrics, and one of them has to sort it. They sort it using the following criteria:

  • Ada sorts in lexicographically increasing order by color (C\mathbf{C}).
  • Charles sorts in ascending order by durability (D\mathbf{D}).
  • They break ties by sorting in ascending order by the unique identifier (U\mathbf{U}).

Given N\mathbf{N} fabrics, count the number of fabrics which end up in the same position regardless of whether Ada or Charles sort them.

입력

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow.

Each test case begins with one line consisting of an integer N\mathbf{N} denoting the number of fabrics. Then N\mathbf{N} lines follow, each line with a string C_i\mathbf{C\_i}, an integer D_i\mathbf{D\_i}, and an integer U_i\mathbf{U\_i}: the color, the durability and the unique identifier of the ii-th fabric respectively.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the number of fabrics which end up in the same position regardless of whether a worker sorts them by color or by durability.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 11 \le length of string C_i\mathbf{C\_i} 10\le 10.
  • String C_i\mathbf{C\_i} consists of only lowercase letters of the English alphabet.
  • No two fabrics have same U_i\mathbf{U\_i}.