The 3rd IUPC

Count how many distinct values appear among all A_i times B_i^p for p = 0..C_i, across N lines with huge exponents.

Hard8Number theoryHash mapMathCombinatoricsNo attempts yetTime limit2sMemory limit256 MB

Problem

IUPC (International University student Product Contest) is a contest where teams of three compete on how fast and how accurately they multiply large numbers. Inha University took the grand prize at the first contest with the team "I inha U", and again at the second contest with the team "URF". The third IUPC is held today.

The day is a happy one, but the competing teams are uneasy. CTP, which runs the contest, decided that Inha University winning every time hurts the morale of the other universities, so it changed the rules.

The old contest was simple: two large numbers were given and a team multiplied them as fast as it could. The third IUPC runs as follows.

  1. AA, BB and CC are given in order on NN lines.
  2. Call the values on line ii by the names AiA_i, BiB_i and CiC_i. For every ii, compute Ai×Bi0A_i \times B_i^0, Ai×Bi1A_i \times B_i^1, Ai×Bi2A_i \times B_i^2, \dots, Ai×BiCiA_i \times B_i^{C_i} and write each result on its own card.
  3. Once all the multiplications are done there are i=1N(Ci+1)\sum_{i=1}^{N}{(C_i+1)} cards. Gather the cards that carry the same number into one group.
  4. After the grouping there are KK groups. KK can equal the number of cards or be smaller than it. The team that computes KK first wins.

Input

The first line contains NN (1N1001 \le N \le 100). Each of the next NN lines contains AiA_i, BiB_i and CiC_i separated by spaces. (2Ai,Bi100,0002 \le A_i, B_i \le 100{,}000, 1Ci100,0001 \le C_i \le 100{,}000)

Output

Print KK, the number of groups formed when the cards are sorted by the rules above, on the first line.