#include <bits/stdc++.h>
using namespace std;
const int maxN = 7000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
int p1[maxN];
char s1[maxN];
int p2[maxN];
char s2[maxN];
int pw[maxN];
unordered_map<int, int> mp1;
unordered_map<int, int> mp2;
int main() {
  pw[0] = 1;
  for (int i = 1; i < maxN; i++) pw[i] = pw[i - 1] * 701;
  int m1 = 1, m2 = 1;
  int n;
  cin >> n;
  int ans = 1;
  mp1[0] = mp2[0] = 1;
  for (int i = 0; i < n; i++) {
    int x, t;
    char c;
    cin >> x >> t >> c;
    t--;
    x = 3 - x;
    if (x == 1) {
      p1[m1] = t, s1[m1] = c;
      int tmp = m1;
      int hs = 0;
      mp1[0]++;
      ans += mp2[0];
      while (tmp) {
        hs *= 701, hs += s1[tmp];
        mp1[hs]++;
        ans += mp2[hs];
        tmp = p1[tmp];
      }
      m1++;
    } else {
      p2[m2] = t;
      s2[m2] = c;
      int tmp = m2;
      int hs = 0, st = 0;
      while (tmp) {
        hs += pw[st] * s2[tmp];
        st++;
        tmp = p2[tmp];
      }
      mp2[hs]++;
      ans += mp1[hs];
      m2++;
    }
    cout << ans << endl;
  }
  return 0;
}
