#include <bits/stdc++.h>
using namespace std;
const unsigned long long P = 29;
int n1, n2;
vector<vector<int> > chi2;
vector<int> par2;
vector<unsigned long long> vhs1, vps1, vhs2;
const int HSZ = 1 << 15;
const int HMSK = HSZ - 1;
vector<pair<unsigned long long, int> > htbl[2][HSZ];
int hver[2][HSZ];
int lhver[2];
void addTbl(int id, unsigned long long h, int k) {
  int pos = h & HMSK;
  if (hver[id][pos] < lhver[id]) {
    htbl[id][pos].clear();
    hver[id][pos] = lhver[id];
  }
  for (vector<pair<unsigned long long, int> >::iterator it =
           htbl[id][pos].begin();
       it != htbl[id][pos].end(); it++)
    if (it->first == h) {
      it->second += k;
      return;
    }
  htbl[id][pos].push_back(make_pair(h, k));
}
int getTbl(int id, unsigned long long h) {
  int pos = h & HMSK;
  if (hver[id][pos] < lhver[id]) {
    htbl[id][pos].clear();
    hver[id][pos] = lhver[id];
  }
  for (vector<pair<unsigned long long, int> >::iterator it =
           htbl[id][pos].begin();
       it != htbl[id][pos].end(); it++)
    if (it->first == h) return it->second;
  return 0;
}
unsigned long long toFind, findK;
int dfs(int v) {
  unsigned long long curFind = toFind + vhs2[v] * findK;
  addTbl(1, curFind, 1);
  int res = 0;
  res += getTbl(1, vhs2[v]);
  for (int i = 0; i < ((int)(chi2[v]).size()); i++) res += dfs(chi2[v][i]);
  addTbl(1, curFind, -1);
  return res;
}
int solve(unsigned long long h, unsigned long long k) {
  toFind = h;
  findK = k;
  lhver[1]++;
  return dfs(0);
}
int main() {
  int ops;
  while (scanf("%d", &ops) >= 1) {
    vhs1 = vector<unsigned long long>(1, 0);
    vps1 = vector<unsigned long long>(1, 1);
    vhs2 = vector<unsigned long long>(1, 0);
    par2 = vector<int>(1, -1);
    n1 = n2 = 1;
    memset(hver, 0, sizeof hver);
    memset(lhver, 0, sizeof lhver);
    for (int i = 0; i < HSZ; i++) {
      htbl[0][i].clear();
      htbl[0][i].reserve(10);
    }
    for (int i = 0; i < HSZ; i++) {
      htbl[1][i].clear();
      htbl[1][i].reserve(10);
    }
    addTbl(0, 0, 1);
    long long cans = 1;
    chi2 = vector<vector<int> >(1);
    while (ops-- > 0) {
      int t, v;
      char c;
      scanf(" %d%d %c", &t, &v, &c), v--;
      if (t == 1) {
        assert(v <= n1);
        vhs1.push_back(vhs1[v] + vps1[v] * c);
        vps1.push_back(vps1[v] * P);
        addTbl(0, vhs1[n1], 1);
        cans += solve(vhs1[n1], vps1[n1]);
        n1++;
      } else {
        assert(v <= n2);
        vhs2.push_back(vhs2[v] * P + c);
        chi2[v].push_back(n2);
        chi2.push_back(vector<int>());
        par2.push_back(v);
        unsigned long long ck = 1;
        for (int x = n2; x >= 0; x = par2[x], ck *= P) {
          unsigned long long ch = vhs2[n2] - vhs2[x] * ck;
          cans += getTbl(0, ch);
        }
        n2++;
      }
      printf("%I64d\n", cans);
    }
  }
  return 0;
}
