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>
using namespace std;
const long long MOD = 1e9 + 7;
long long qpow(long long x, long long a) {
  long long res = x, ret = 1;
  while (a > 0) {
    if ((a & 1LL) == 1) ret = ret * res % MOD;
    a >>= 1LL;
    res = res * res % MOD;
  }
  return ret;
}
long long v[200010], q, n = 1, fa[200010], bg[200010], ed[200010], len = 0,
                        deg[200010];
vector<pair<long long, long long> > qry;
vector<long long> g[200010];
void dfs(long long pos, long long par) {
  fa[pos] = par;
  bg[pos] = len++;
  for (int i = 0; i < g[pos].size(); i++)
    if (g[pos][i] != par) dfs(g[pos][i], pos);
  ed[pos] = len - 1;
}
namespace st {
long long n2 = 1, sum[800010], mul[800010], tag[800010];
void pushDown(long long k) {
  for (long long i = k + k + 1; i <= k + k + 2; ++i) {
    mul[i] = mul[i] * tag[k] % MOD;
    sum[i] = sum[i] * tag[k] % MOD;
    tag[i] = tag[i] * tag[k] % MOD;
  }
  tag[k] = 1;
}
void upd(long long k, long long lb, long long ub, long long tlb, long long tub,
         long long val) {
  if (ub < tlb || tub < lb) return;
  if (tlb <= lb && ub <= tub) {
    mul[k] = mul[k] * val % MOD;
    sum[k] = sum[k] * val % MOD;
    tag[k] = tag[k] * val % MOD;
    return;
  }
  pushDown(k);
  upd(k + k + 1, lb, (lb + ub) / 2, tlb, tub, val);
  upd(k + k + 2, (lb + ub) / 2 + 1, ub, tlb, tub, val);
  sum[k] = (sum[k + k + 1] + sum[k + k + 2]) % MOD;
}
void updp(long long k, long long lb, long long ub, long long to,
          long long val) {
  if (lb == ub) {
    sum[k] = mul[k] * val % MOD;
    return;
  }
  pushDown(k);
  long long mid = (lb + ub) / 2;
  if (to <= mid)
    updp(k + k + 1, lb, mid, to, val);
  else
    updp(k + k + 2, mid + 1, ub, to, val);
  sum[k] = (sum[k + k + 1] + sum[k + k + 2]) % MOD;
}
long long get(long long k, long long lb, long long ub, long long tlb,
              long long tub) {
  if (ub < tlb || tub < lb) return 0;
  if (tlb <= lb && ub <= tub) return sum[k];
  pushDown(k);
  return (get(k + k + 1, lb, (lb + ub) / 2, tlb, tub) +
          get(k + k + 2, (lb + ub) / 2 + 1, ub, tlb, tub)) %
         MOD;
}
long long getMul(long long k, long long lb, long long ub, long long to) {
  if (lb == ub) return mul[k];
  pushDown(k);
  long long mid = (lb + ub) / 2;
  if (to <= mid) return getMul(k + k + 1, lb, mid, to);
  return getMul(k + k + 2, mid + 1, ub, to);
}
}  // namespace st
int main() {
  cin >> v[1] >> q;
  long long x, y;
  for (int i = 0; i < q; i++) {
    scanf("%I64d", &x);
    if (x == 1) {
      scanf("%I64d%I64d", &x, &y);
      ++n;
      g[x].push_back(n);
      g[n].push_back(x);
      v[n] = y;
      qry.push_back(make_pair(x, n));
    } else {
      scanf("%I64d", &x);
      qry.push_back(make_pair(-1, x));
    }
  }
  dfs(1, 0);
  while (st::n2 < n) st::n2 *= 2;
  for (int i = 0; i < st::n2 + st::n2 + 5; i++) st::mul[i] = st::tag[i] = 1;
  for (int i = 1; i <= n; i++) deg[i] = 1;
  st::updp(0, 0, st::n2 - 1, bg[1], v[1]);
  for (int qn = 0; qn < q; qn++) {
    if (qry[qn].first != -1) {
      ++deg[qry[qn].first];
      st::upd(0, 0, st::n2 - 1, bg[qry[qn].first], ed[qry[qn].first],
              deg[qry[qn].first] * qpow(deg[qry[qn].first] - 1, MOD - 2) % MOD);
      st::updp(0, 0, st::n2 - 1, bg[qry[qn].second], v[qry[qn].second]);
    } else {
      long long res = st::get(0, 0, st::n2 - 1, bg[qry[qn].second],
                              ed[qry[qn].second]),
                div = qry[qn].second == 1 ? 1
                                          : st::getMul(0, 0, st::n2 - 1,
                                                       bg[fa[qry[qn].second]]);
      printf("%I64d\n", res * qpow(div, MOD - 2) % MOD);
    }
  }
  return 0;
}