Problem: Genos and Saitama went shopping for Christmas trees. However, a different type of tree caught their attention, the exalted Power Tree. 

A Power Tree starts out as a single root vertex indexed 1. A Power Tree grows through a magical phenomenon known as an update. In an update, a single vertex is added to the tree as a child of some other vertex.

Every vertex in the tree (the root and all the added vertices) has some value vi associated with it. The power of a vertex is defined as the strength of the multiset composed of the value associated with this vertex (vi) and the powers of its direct children. The strength of a multiset is defined as the sum of all elements in the multiset multiplied by the number of elements in it. Or in other words for some multiset S: 

<image>

Saitama knows the updates that will be performed on the tree, so he decided to test Genos by asking him queries about the tree during its growth cycle.

An update is of the form 1 p v, and adds a new vertex with value v as a child of vertex p.

A query is of the form 2 u, and asks for the power of vertex u.

Please help Genos respond to these queries modulo 109 + 7.

Input

The first line of the input contains two space separated integers v1 and q (1 ≤ v1 < 109, 1 ≤ q ≤ 200 000) — the value of vertex 1 and the total number of updates and queries respectively.

The next q lines contain the updates and queries. Each of them has one of the following forms: 

  * 1 pi vi, if these line describes an update. The index of the added vertex is equal to the smallest positive integer not yet used as an index in the tree. It is guaranteed that pi is some already existing vertex and 1 ≤ vi < 109. 
  * 2 ui, if these line describes a query. It is guaranteed ui will exist in the tree. 



It is guaranteed that the input will contain at least one query.

Output

For each query, print out the power of the given vertex modulo 109 + 7.

Examples

Input

2 5
1 1 3
1 2 5
1 3 7
1 4 11
2 1


Output

344


Input

5 5
1 1 4
1 2 3
2 2
1 2 7
2 1


Output

14
94

Note

For the first sample case, after all the updates the graph will have vertices labelled in the following manner: 1 — 2 — 3 — 4 — 5

These vertices will have corresponding values: 2 — 3 — 5 — 7 — 11

And corresponding powers: 344 — 170 — 82 — 36 — 11

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
vector<long long> v[200005];
long long l[200005], r[200005], b[200005], t[200005], fa[200005], a[200005],
    cnt, mod = 1e9 + 7, siz[200005];
void dfs(long long x, long long y) {
  l[x] = ++cnt;
  for (auto u : v[x])
    if (u != y) {
      dfs(u, x);
    }
  r[x] = cnt;
}
long long tag[1 << 19], val[1 << 19], mul[1 << 19];
void build(long long x, long long l, long long r) {
  tag[x] = 1;
  mul[x] = 1;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  build((x << 1), l, mid);
  build(((x << 1) | 1), mid + 1, r);
}
void pushdown(long long x, long long l, long long r) {
  if (l != r) {
    tag[(x << 1)] = tag[(x << 1)] * tag[x] % mod;
    tag[((x << 1) | 1)] = tag[((x << 1) | 1)] * tag[x] % mod;
    mul[(x << 1)] = mul[(x << 1)] * tag[x] % mod;
    mul[((x << 1) | 1)] = mul[((x << 1) | 1)] * tag[x] % mod;
    val[(x << 1)] = val[(x << 1)] * tag[x] % mod;
    val[((x << 1) | 1)] = val[((x << 1) | 1)] * tag[x] % mod;
  }
  tag[x] = 1;
}
void update(long long x, long long l, long long r, long long tl, long long tr,
            long long muti) {
  pushdown(x, l, r);
  if (l >= tl && r <= tr) {
    tag[x] = tag[x] * muti % mod;
    mul[x] = mul[x] * muti % mod;
    val[x] = val[x] * muti % mod;
    return;
  }
  if (l > tr || tl > r) return;
  long long mid = (l + r) >> 1;
  update((x << 1), l, mid, tl, tr, muti);
  update(((x << 1) | 1), mid + 1, r, tl, tr, muti);
  val[x] = (val[(x << 1)] + val[((x << 1) | 1)]) % mod;
}
void update1(long long x, long long l, long long r, long long it,
             long long add) {
  pushdown(x, l, r);
  if (l == r) {
    val[x] = (val[x] + add * mul[x]) % mod;
    return;
  }
  long long mid = (l + r) >> 1;
  if (mid >= it)
    update1((x << 1), l, mid, it, add);
  else
    update1(((x << 1) | 1), mid + 1, r, it, add);
  val[x] = (val[(x << 1)] + val[((x << 1) | 1)]) % mod;
}
long long get(long long x, long long l, long long r, long long it) {
  pushdown(x, l, r);
  if (l == r) return mul[x];
  long long mid = (l + r) >> 1;
  if (mid >= it) {
    return get((x << 1), l, mid, it);
  } else
    return get(((x << 1) | 1), mid + 1, r, it);
}
long long getval(long long x, long long l, long long r, long long tl,
                 long long tr) {
  pushdown(x, l, r);
  if (l >= tl && r <= tr) return val[x];
  if (l > tr || tl > r) return 0;
  long long mid = (l + r) >> 1;
  return (getval((x << 1), l, mid, tl, tr) +
          getval(((x << 1) | 1), mid + 1, r, tl, tr)) %
         mod;
}
long long __pow(long long x, long long y) {
  if (!y) return 1;
  long long t = __pow(x, y / 2);
  if (y & 1) {
    return t * t % mod * x % mod;
  } else
    return t * t % mod;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, q;
  n = 1;
  cin >> a[1] >> q;
  for (long long i = 1; i <= q; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      long long x, y;
      cin >> x >> y;
      fa[++n] = x;
      v[x].emplace_back(n);
      a[n] = y;
    } else
      cin >> b[i];
  }
  dfs(1, -1);
  build(1, 1, n);
  long long tn = 1;
  update1(1, 1, n, 1, a[1]);
  for (long long i = 1; i <= n; i++) siz[i] = 1;
  for (long long i = 1; i <= q; i++) {
    if (t[i] == 1) {
      tn++;
      update(1, 1, n, l[fa[tn]], r[fa[tn]],
             __pow(siz[fa[tn]], mod - 2) * (++siz[fa[tn]]) % mod);
      update1(1, 1, n, l[tn], a[tn]);
    } else {
      cout << getval(1, 1, n, l[b[i]], r[b[i]]) *
                  (b[i] == 1 ? 1 : __pow(get(1, 1, n, l[fa[b[i]]]), mod - 2)) %
                  mod
           << '\n';
    }
  }
  return 0;
}