1 import java.io.PrintWriter;
2 import java.util.Arrays;
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.Scanner;
6
7 public class Main {
8 static Scanner cin = new Scanner(System.in);
9 static PrintWriter cout = new PrintWriter(System.out);
10
11 public static void main(String[] args) {
12 Map<String, Integer> map = new HashMap<String, Integer>();
13 for (int n = cin.nextInt(); n-- > 0;) {
14 char cs[] = cin.next().toCharArray();
15 Arrays.sort(cs);
16 String s = new String(cs);
17 if (!map.containsKey(s))
18 map.put(s, 0);
19 cout.println(map.get(s));
20 map.put(s, 1 + map.get(s));
21
22 }
23 cin.close();
24 cout.close();
25 }
26 }