#include <bits/stdc++.h>
using namespace std;
struct BIT {
  long long v[100005];
  long long q(int i) {
    long long r = 0;
    for (; i; i -= i & -i) r += v[i];
    return r;
  }
  void u(int i, long long r) {
    for (; i < 100005; i += i & -i) v[i] += r;
  }
} b1, b2;
pair<long long, long long> P[100005];
int x[100005][26], y[100005][26];
int xd[100005], yd[100005];
int xp[100005], yp[17][100005];
int xw[100005], yw[100005];
pair<long long, long long> xh[100005], yh[100005];
int ytx[100005];
int n;
int s1, s2;
int op[100005];
int no[100005];
long long ans[100005];
map<pair<long long, long long>, int> mp;
long long fx(long long a, long long m) { return a >= m ? a - m : a; }
pair<long long, long long> add(pair<long long, long long> a,
                               pair<long long, long long> b) {
  return pair<long long, long long>(fx(a.first + b.first, 1000000007ll),
                                    fx(a.second + b.second, 1000000009ll));
}
pair<long long, long long> sub(pair<long long, long long> a,
                               pair<long long, long long> b) {
  return pair<long long, long long>(
      fx(a.first - b.first + 1000000007ll, 1000000007ll),
      fx(a.second - b.second + 1000000009ll, 1000000009ll));
}
pair<long long, long long> mul(pair<long long, long long> a,
                               pair<long long, long long> b) {
  return pair<long long, long long>(a.first * b.first % 1000000007ll,
                                    a.second * b.second % 1000000009ll);
}
pair<long long, long long> yhash(int i, int j) {
  return mul(sub(yh[j], yh[i]), P[100004 - yd[j]]);
}
int l[100005], r[100005], T;
void go(int i) {
  ++T;
  l[i] = T;
  for (int j = (0); j < (26); j++)
    if (x[i][j]) go(x[i][j]);
  r[i] = T;
}
int main() {
  s1 = 1, s2 = 1;
  scanf("%d", &n);
  P[0] = {1, 1};
  for (int i = (1); i < (100005); i++) P[i] = mul(P[i - 1], {137, 137});
  mp[{0, 0}] = 1;
  xw[1] = yw[1] = 1;
  no[1] = 1;
  for (int i = (0); i < (n); i++) {
    int t, pr;
    char ch;
    scanf("%d%d %c", &t, &pr, &ch);
    op[i] = t;
    if (t == 1) {
      pr = xw[pr];
      s1++;
      if (!x[pr][ch - 'a']) {
        xp[s1] = pr;
        xd[s1] = xd[pr] + 1;
        x[pr][ch - 'a'] = s1;
        xh[s1] = add(mul(xh[pr], {137, 137}), {ch, ch});
        mp[mul(xh[s1], P[100004 - xd[s1]])] = s1;
      }
      xw[s1] = x[pr][ch - 'a'];
    } else {
      pr = yw[pr];
      s2++;
      if (!y[pr][ch - 'a']) {
        yp[0][s2] = pr;
        yd[s2] = yd[pr] + 1;
        y[pr][ch - 'a'] = s2;
        yh[s2] = add(yh[pr], mul(P[yd[pr]], {ch, ch}));
      }
      yw[s2] = y[pr][ch - 'a'];
    }
  }
  for (int i = (1); i < (17); i++)
    for (int j = (1); j < (s2 + 1); j++)
      if (yw[j] == j) {
        yp[i][j] = yp[i - 1][yp[i - 1][j]];
      }
  for (int j = (1); j < (s2 + 1); j++) {
    if (yw[j] == j) {
      int cp = j;
      for (int i = 16; i >= 0; i--) {
        int np = yp[i][cp];
        if (np && mp.count(yhash(np, j))) cp = np;
      }
      ytx[j] = mp[yhash(cp, j)];
    } else
      ytx[j] = ytx[yw[j]];
  }
  go(1);
  long long res = 1;
  b2.u(l[1], 1);
  b2.u(r[1] + 1, -1);
  b1.u(l[1], 1);
  s1 = 1, s2 = 1;
  for (int Z = (0); Z < (n); Z++) {
    int t = op[Z];
    if (t == 1) {
      s1++;
      int i = xw[s1];
      res += b1.q(r[i]) - b1.q(l[i] - 1);
      b2.u(l[i], 1);
      b2.u(r[i] + 1, -1);
    } else {
      s2++;
      int i = ytx[s2];
      res += b2.q(l[i]);
      b1.u(l[i], 1);
    }
    printf("%lld\n", res);
  }
}
