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 int N = 200007;
const long long int MOD = 1e9 + 7ll;
struct seg {
  long long int v[4 * N], lz[4 * N];
  int l[4 * N], r[4 * N];
  int lo, hi;
  void build(int u, int lo, int hi) {
    l[u] = lo;
    r[u] = hi;
    v[u] = 0;
    lz[u] = 1ll;
    if (lo + 1 == hi) return;
    build(2 * u, lo, (lo + hi) / 2);
    build(2 * u + 1, (lo + hi) / 2, hi);
  }
  void refresh(int u) {
    v[u] = (v[u] * lz[u]) % MOD;
    if (l[u] + 1 != r[u]) {
      lz[2 * u] = (lz[2 * u] * lz[u]) % MOD;
      lz[2 * u + 1] = (lz[2 * u + 1] * lz[u]) % MOD;
    }
    lz[u] = 1;
  }
  void add(int u, int p, long long int x) {
    refresh(u);
    if (l[u] + 1 == r[u] && l[u] == p) {
      v[u] = (v[u] + x) % MOD;
      assert(v[u] == x);
      return;
    }
    if (l[u] > p || r[u] <= p) return;
    add(2 * u, p, x);
    add(2 * u + 1, p, x);
    v[u] = (v[2 * u] + v[2 * u + 1]) % MOD;
  }
  void times(int l, int r, long long int x) {
    lo = l;
    hi = r;
    times(1, x);
  }
  void times(int u, long long int x) {
    refresh(u);
    if (l[u] >= lo && r[u] <= hi) {
      lz[u] = (lz[u] * x) % MOD;
      assert(lz[u] == x);
      refresh(u);
      return;
    }
    if (l[u] >= hi || r[u] <= lo) return;
    times(2 * u, x);
    times(2 * u + 1, x);
    v[u] = (v[2 * u] + v[2 * u + 1]) % MOD;
  }
  long long int query(int l, int r) {
    lo = l;
    hi = r;
    return query(1);
  }
  long long int query(int u) {
    refresh(u);
    if (l[u] >= lo && r[u] <= hi) return v[u];
    if (l[u] >= hi || r[u] <= lo) return 0ll;
    return (query(2 * u) + query(2 * u + 1)) % MOD;
  }
};
struct qr {
  int t, u;
};
long long int fexp(long long int x, long long int e) {
  long long int r = 1ll;
  while (e) {
    if (e % 2) r = (r * x) % MOD;
    x = (x * x) % MOD;
    e /= 2;
  }
  return r;
}
long long int inv(long long int x) { return fexp(x, MOD - 2); }
int hd[N], to[N], nx[N], es;
int pr[N];
long long int sz[N];
int ord[N][2], os;
qr q[N];
long long int v[N];
int n, qrs;
void dfs(int u) {
  ord[u][0] = os++;
  for (int ed = hd[u]; ed; ed = nx[ed]) dfs(to[ed]);
  ord[u][1] = os;
}
seg tree;
int main() {
  scanf("%lld %d", &v[0], &qrs);
  n = 1;
  es = 2;
  for (int i = 0; i < qrs; i++) {
    scanf("%d %d", &q[i].t, &q[i].u);
    q[i].u--;
    if (q[i].t == 1) {
      scanf("%lld", &v[n]);
      pr[n] = q[i].u;
      nx[es] = hd[q[i].u];
      to[es] = n++;
      hd[q[i].u] = es++;
    }
  }
  dfs(0);
  tree.build(1, 0, n);
  sz[0] = 1ll;
  tree.add(1, ord[0][0], v[0]);
  int qt = 1;
  for (int i = 0; i < qrs; i++) {
    int u = q[i].u;
    if (q[i].t == 1) {
      sz[qt] = 1ll;
      tree.times(ord[u][0], ord[u][1], ((sz[u] + 1ll) * inv(sz[u])) % MOD);
      sz[u]++;
      long long int s = tree.query(ord[u][0], ord[u][0] + 1);
      s = (s * inv(v[u])) % MOD;
      s = (s * v[qt]) % MOD;
      tree.add(1, ord[qt][0], s);
      qt++;
    } else {
      long long int s = 1ll;
      s = (inv(tree.query(ord[u][0], ord[u][0] + 1)) * v[u]) % MOD;
      s = (s * sz[u]) % MOD;
      s = (s * tree.query(ord[u][0], ord[u][1])) % MOD;
      printf("%lld\n", s);
    }
  }
}