The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independently come up with the coordinate to which that ship will jump. In the obsolete navigation system used by the Rebels, this coordinate is given as the value of an arithmetic expression of the form <image>.

To plan the future of the resistance movement, Princess Heidi needs to know, for each ship, how many ships are going to end up at the same coordinate after the jump. You are her only hope!

Input

The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) – the number of ships. The next m lines describe one jump coordinate each, given as an arithmetic expression. An expression has the form (a+b)/c. Namely, it consists of: an opening parenthesis (, a positive integer a of up to two decimal digits, a plus sign +, a positive integer b of up to two decimal digits, a closing parenthesis ), a slash /, and a positive integer c of up to two decimal digits.

Output

Print a single line consisting of m space-separated integers. The i-th integer should be equal to the number of ships whose coordinate is equal to that of the i-th ship (including the i-th ship itself).

Example

Input

4
(99+98)/97
(26+4)/10
(12+33)/15
(5+1)/7


Output

1 2 2 1 

Note

In the sample testcase, the second and the third ship will both end up at the coordinate 3.

Note that this problem has only two versions – easy and hard.
	import java.io.*;
	import java.util.*;
	import java.math.*;
	
	 
	 public class Main	{
	   static class Pair implements Comparable<Pair>{
	   int a;
	   int b;
	   public Pair(){}
	   public Pair(int x,int y){a=x;b=y;}
	   public int compareTo(Pair p){
		 return Integer.compare(a, p.a);
	   }
//		   long a,b;
//		   public Pair(long x,long y){a=x;b=y;}
//		   public int compareTo(Pair p){
//				 return Long.compare(a, p.a);
//		   }
//		  
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + a;
			result = prime * result + b;
		   
			return result;
		}
		@Override
		public boolean equals(Object obj) {
			Pair cur = (Pair)obj;
			if((a==cur.a && b==cur.b))return true;
			return false;
		}
	 }
	   static class ArrayUtils {
		public static Integer[] generateOrder(int size) {
			Integer[] order = new Integer[size];
			for (int i = 0; i < size; i++)
				order[i] = i;
			return order;
		}
	 
		public static Integer[] order(int size, Comparator<Integer> comparator) {
			Integer[] order = generateOrder(size);
			Arrays.sort(order, comparator);
			return order;
		}
	 
			}
	   static class cell implements Comparable<cell>{
		   int a,b;
		   long dis;
		   public cell(int x,int y,long z) {a=x;b=y;dis=z;}
		   public int compareTo(cell c) {
			   return Long.compare(dis,c.dis);
		   }
	   }
	static class TrieNode{
		TrieNode left;
		TrieNode right;
		int op;
		int data;
		public TrieNode() {}
	}
	  public static int gcd(int a,int b)
	  {
	    if(a<b)
	      return gcd(b,a);
	    if(b==0)
	      return a;
	    return gcd(b,a%b);
	    
	  }
	  static int lcm(int a,int b) {
		  return  a*b / gcd(a,b);
	  }
	  //static long ans = 0;
	  static long mod = (long)(1e9+7); //998244353;//
	   
	    public static void main(String[] args) throws Exception {
	       new Thread(null, null, "Anshum Gupta", 99999999) {
	            public void run() {
	                try {
	                    solve();
	                } catch(Exception e) {
	                    e.printStackTrace();
	                    System.exit(1);
	                }
	            }
	        }.start();
	    }
	
	static long pow(long x,long y){
	    if(y == 0)return 1;
	    if(y==1)return x;
	    long a = pow(x,y/2);
	    a = (a*a)%mod;
	    if(y%2==0){
	        return a;
	    }
	    return (a*x)%mod;
	}
	
	static long mxx;
	static int mxN = (int)(2e6+5);
	static long[]fact,inv_fact;
	static long my_inv(long a) {
		return pow(a,mod-2);
	}
	static long bin(int a,int b) {
		if(a < b || a<0 || b<0)return 0;
	    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
	}
		static ArrayList<ArrayList<Integer>>adj;
		static boolean[]vis;
	static void make_facts() {
	  fact=new long[mxN];
	  inv_fact = new long[mxN];
	  fact[0]=inv_fact[0]=1L;
	  for(int i=1;i<mxN;i++) {
		   fact[i] = (i*fact[i-1])%mod;
		   inv_fact[i] = my_inv(fact[i]);
	  }
	}
	
	 public static void solve() throws Exception {
	   // solve the problem here
	   MyScanner s = new MyScanner();
	        out = new PrintWriter(new BufferedOutputStream(System.out), true);
	        int tc = 1;//s.nextInt();
	        mxx = (long)(1e18+5);
	//	        make_facts(); 
	//	        int mod = (int)1e9+7;
	        while(tc-->0){
	        	int m = s.nextInt();
	        	String[]arr = new String[m];
	        	int[]nums = new int[m];
	        	int[]den = new int[m];
	        	HashMap<Pair, Integer> mp = new HashMap<Main.Pair, Integer>();
	        	for(int i=0;i<m;i++) {
	        		arr[i] = s.next();
	        		int j = 1;
    				int a = 0, b = 0, c = 0;
    				int cnt = 0;
    				while(arr[i].charAt(j) != '+') {
    					j++;
    					cnt++;
    				}
    				
    				if(cnt == 2) {
    					a = (arr[i].charAt(j-2) - '0') * 10 + (arr[i].charAt(j-1) - '0') ;
    				}
    				else {
    					a = (arr[i].charAt(j-1) - '0');
    				}
    				cnt = 0;
    				j++;
    				while(arr[i].charAt(j) != ')') {
    					j++;
    					cnt++;
    				}
    				if(cnt == 2) {
    					b = (arr[i].charAt(j-2) - '0') * 10 + (arr[i].charAt(j-1) - '0') ;
    				}
    				else {
    					b = (arr[i].charAt(j-1) - '0');
    				}	
    				j+=2;
    				cnt = 0;
    				while(j < arr[i].length()) {
    					j++;
    					cnt++;
    				}
    				if(cnt == 2) {
    					c = (arr[i].charAt(j-2) - '0') * 10 + (arr[i].charAt(j-1) - '0') ;
    				}
    				else {
    					c = (arr[i].charAt(j-1) - '0');
    				}
//    				out.println(a + " " + b + " " + c);
	        		int g = (int)gcd(a+b, c);	
	        		nums[i] = (a+b)/g;
	        		den[i] = c/g;
	        		Pair cur = new Pair(nums[i], den[i]);
	        		if(mp.containsKey(cur)) {
	        			mp.put(cur, mp.get(cur) + 1);
	        		}
	        		else {
	        			mp.put(cur,1);
	        		}
	        	}
	        	for(int i=0;i<m;i++) {
	        		int x = mp.get(new Pair(nums[i], den[i]));
	        		out.print(x + " ");
	        	}
	        	
	        	
	        }
	        	
	           
	        out.flush();
	}
	 
	     
	 
	 
	 
	    //-----------PrintWriter for faster output---------------------------------
	    public static PrintWriter out;
	 
	    //-----------MyScanner class for faster input----------
	    public static class MyScanner {
	        BufferedReader br;
	        StringTokenizer st;
	 
	        public MyScanner() {
	            br = new BufferedReader(new InputStreamReader(System.in));
	        }
	 
	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine());
	                } catch (IOException e) {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }
	 
	        int nextInt() { return Integer.parseInt(next()); }
	        long nextLong() { return Long.parseLong(next()); }
	        double nextDouble() { return Double.parseDouble(next()); }
	         
	        String nextLine(){
	            String str = "";
	            try {
	                str = br.readLine();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }
	    //--------------------------------------------------------
	}
