from fractions import gcd from collections import defaultdict for cas in xrange(input()): s = defaultdict(set) for i in xrange(input()): a, b, c = map(int, raw_input().strip().split()) g = gcd(a, b) h = gcd(g, c) s[a/g, b/g].add((a/h, b/h, c/h)) print max(map(len, s.values()))