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 MBIUPC (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.
The first line contains N (1≤N≤100). Each of the next N lines contains Ai, Bi and Ci separated by spaces. (2≤Ai,Bi≤100,000, 1≤Ci≤100,000)
Print K, the number of groups formed when the cards are sorted by the rules above, on the first line.