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.sql.Array;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        //  Reader.init(new File("greater.in"));
        Reader.init(System.in);
        // PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        PrintWriter out = new PrintWriter(System.out);
        // BufferedReader br = new BufferedReader(new FileReader(new File("input.txt")));
        //     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int M = Reader.nextInt();
        HashMap<String, Integer> count = new HashMap<>();
        String[] proper = new String[M];
        for(int i = 0; i < M; i++){
            String[] S = Reader.next().trim().split("/");
            int pos = -1;
            for(int j = 1; j < S[0].length()-1; j++){
                if(S[0].charAt(j) == '+') pos = j;
            }
            int a = Integer.parseInt(S[0].substring(1, pos));
            a += Integer.parseInt(S[0].substring(pos+1, S[0].length() - 1));
            int c = Integer.parseInt(S[1]);
            int g = gcd(a, c);
            a /= g;
            c /= g;
            proper[i] = a + " " + c;
            if(count.containsKey(proper[i])) count.put(proper[i], count.get(proper[i]) + 1);
            else count.put(proper[i], 1);
        }
        for(int i = 0; i < M; i++){
            out.print(count.get(proper[i]) + " ");
        }
        out.close();
    }

    static int gcd(int a, int b){
        if(a < b) return gcd(b,a);
        if(b == 0) return a;
        else return gcd(b, a%b);
    }


}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(File filename) {
        try {
            reader = new BufferedReader(new FileReader(filename));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        tokenizer = new StringTokenizer("");
    }

    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String nextToken() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() {

        return Long.parseLong(nextToken());
    }
}




