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 = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 201000;
int l[N], r[N], deg[N], val[N], rr[N], tot, q, ty[N], n, p[N];
vector<int> e[N];
void dfs(int u) {
  l[u] = ++tot;
  for (auto v : e[u]) {
    dfs(v);
  }
  r[u] = tot;
}
struct node {
  long long fg, dg, sm;
} nd[N * 4];
void setc(int p, long long c) {
  nd[p].fg = nd[p].fg * c % mod;
  nd[p].sm = nd[p].sm * c % mod;
  nd[p].dg = nd[p].dg * c % mod;
}
void push(int p) {
  if (nd[p].fg != 1) {
    setc(p + p, nd[p].fg);
    setc(p + p + 1, nd[p].fg);
    nd[p].fg = 1;
  }
}
void mul(int p, int l, int r, int tl, int tr, long long c) {
  if (l == tl && r == tr) {
    setc(p, c);
  } else {
    push(p);
    int md = (l + r) >> 1;
    if (tr <= md)
      mul(p + p, l, md, tl, tr, c);
    else if (tl > md)
      mul(p + p + 1, md + 1, r, tl, tr, c);
    else
      mul(p + p, l, md, tl, md, c), mul(p + p + 1, md + 1, r, md + 1, tr, c);
    nd[p].dg = (nd[p + p].dg + nd[p + p + 1].dg) % mod;
    nd[p].sm = (nd[p + p].sm + nd[p + p + 1].sm) % mod;
  }
}
void add(int p, int l, int r, int x, long long c, long long v) {
  if (l == r) {
    assert(nd[p].dg == 0);
    nd[p].dg = (nd[p].dg + c) % mod;
    nd[p].sm = (nd[p].sm + c * v) % mod;
  } else {
    push(p);
    int md = (l + r) >> 1;
    if (x <= md)
      add(p + p, l, md, x, c, v);
    else if (x > md)
      add(p + p + 1, md + 1, r, x, c, v);
    nd[p].dg = (nd[p + p].dg + nd[p + p + 1].dg) % mod;
    nd[p].sm = (nd[p + p].sm + nd[p + p + 1].sm) % mod;
  }
}
long long queryd(int p, int l, int r, int x) {
  if (l == r) {
    return nd[p].dg;
  } else {
    push(p);
    int md = (l + r) >> 1;
    if (x <= md)
      return queryd(p + p, l, md, x);
    else
      return queryd(p + p + 1, md + 1, r, x);
  }
}
long long query(int p, int l, int r, int tl, int tr) {
  if (l == tl && r == tr) {
    return nd[p].sm;
  } else {
    push(p);
    int md = (l + r) >> 1;
    if (tr <= md)
      return query(p + p, l, md, tl, tr);
    else if (tl > md)
      return query(p + p + 1, md + 1, r, tl, tr);
    else
      return (query(p + p, l, md, tl, md) +
              query(p + p + 1, md + 1, r, md + 1, tr)) %
             mod;
  }
}
int main() {
  scanf("%d", val + 1);
  scanf("%d", &q);
  n = 1;
  for (int i = 0; i < q; i++) {
    scanf("%d", ty + i);
    if (ty[i] == 1) {
      n++;
      rr[i] = n;
      scanf("%d%d", p + n, val + n);
      e[p[n]].push_back(n);
    } else {
      scanf("%d", rr + i);
    }
  }
  dfs(1);
  for (int i = 1; i < n + 1; i++) deg[i] = 1;
  add(1, 1, n, 1, 1, val[1]);
  for (int i = 0; i < q; i++) {
    if (ty[i] == 1) {
      int u = p[rr[i]], v = rr[i];
      mul(1, 1, n, l[u], r[u], 1 + powmod(deg[u], mod - 2));
      deg[u]++;
      long long pd = queryd(1, 1, n, l[u]);
      add(1, 1, n, l[v], pd, val[v]);
    } else {
      int u = p[rr[i]], v = rr[i];
      long long ret = query(1, 1, n, l[v], r[v]);
      if (u) ret = ret * powmod(queryd(1, 1, n, l[u]), mod - 2) % mod;
      printf("%lld\n", ret);
    }
  }
}