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>
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
int n, q;
int pre[N], to[N], head[N], wcnt;
int fa[N], val[N], id[N], size[N], deg[N], idcnt;
int qopt[N], qu[N];
int seg[N << 2], mark[N << 2];
int c[N];
inline int qmod(int x) { return (x >= MOD) ? (x - MOD) : x; }
inline int qpow(long long b, int p, int mod = MOD) {
  int res = 1;
  while (p) {
    if (p & 1) res = res * b % mod;
    b = b * b % mod;
    p >>= 1;
  }
  return res;
}
inline void add(int l, int r, int x) {
  for (; l <= n; l += l & -l) c[l] = 1LL * c[l] * x % MOD;
  for (r++, x = qpow(x, MOD - 2); r <= n; r += r & -r)
    c[r] = 1LL * c[r] * x % MOD;
}
inline int query(int p) {
  int res = 1;
  for (; p; p ^= p & -p) res = 1LL * res * c[p] % MOD;
  return res;
}
inline void addedge(int u, int v) {
  pre[++wcnt] = head[u];
  head[u] = wcnt;
  to[wcnt] = v;
}
void dfs(int u) {
  int i;
  id[u] = ++idcnt;
  size[u] = 1;
  for (i = head[u]; i; i = pre[i]) {
    dfs(to[i]);
    size[u] += size[to[i]];
  }
}
inline void mulnode(int p, int x) {
  seg[p] = 1LL * seg[p] * x % MOD;
  mark[p] = 1LL * mark[p] * x % MOD;
}
inline void down(int p) {
  if (mark[p] ^ 1) {
    mulnode((p << 1), mark[p]);
    mulnode((p << 1 | 1), mark[p]);
    mark[p] = 1;
  }
}
void build(int p, int l, int r) {
  mark[p] = 1;
  if (l ^ r) {
    build((p << 1), l, ((l + r) >> 1));
    build((p << 1 | 1), ((l + r) >> 1) + 1, r);
  }
}
void ins(int p, int l, int r, int a, int x) {
  if (l == r) {
    seg[p] = x;
    return;
  }
  down(p);
  if (a <= ((l + r) >> 1))
    ins((p << 1), l, ((l + r) >> 1), a, x);
  else
    ins((p << 1 | 1), ((l + r) >> 1) + 1, r, a, x);
  seg[p] = qmod(seg[(p << 1)] + seg[(p << 1 | 1)]);
}
void mul(int p, int l, int r, int a, int b, int x) {
  if (a <= l and r <= b) {
    mulnode(p, x);
    return;
  }
  down(p);
  if (a <= ((l + r) >> 1)) mul((p << 1), l, ((l + r) >> 1), a, b, x);
  if (b > ((l + r) >> 1)) mul((p << 1 | 1), ((l + r) >> 1) + 1, r, a, b, x);
  seg[p] = qmod(seg[(p << 1)] + seg[(p << 1 | 1)]);
}
int query(int p, int l, int r, int a, int b) {
  if (a <= l and r <= b) return seg[p];
  down(p);
  if (a <= ((l + r) >> 1) and b > ((l + r) >> 1))
    return qmod(query((p << 1), l, ((l + r) >> 1), a, b) +
                query((p << 1 | 1), ((l + r) >> 1) + 1, r, a, b));
  else if (a <= ((l + r) >> 1))
    return query((p << 1), l, ((l + r) >> 1), a, b);
  else
    return query((p << 1 | 1), ((l + r) >> 1) + 1, r, a, b);
}
int main() {
  int i, u;
  scanf("%d %d", &val[1], &q);
  n = 1;
  for (i = int(1); i <= int(q); i++) {
    scanf("%d", &qopt[i]);
    if (qopt[i] == 1) {
      qu[i] = ++n;
      scanf("%d %d", &fa[n], &val[n]);
      addedge(fa[n], n);
    } else
      scanf("%d", &qu[i]);
  }
  dfs(1);
  build(1, 1, n);
  ins(1, 1, n, 1, val[1]);
  for (i = int(1); i <= int(n); i++) c[i] = deg[i] = 1;
  for (i = int(1); i <= int(q); i++) {
    u = qu[i];
    if (qopt[i] == 1) {
      mul(1, 1, n, id[fa[u]], id[fa[u]] + size[fa[u]] - 1,
          qpow(deg[fa[u]], MOD - 2));
      add(id[fa[u]], id[fa[u]] + size[fa[u]] - 1, qpow(deg[fa[u]], MOD - 2));
      deg[fa[u]]++;
      mul(1, 1, n, id[fa[u]], id[fa[u]] + size[fa[u]] - 1, deg[fa[u]]);
      add(id[fa[u]], id[fa[u]] + size[fa[u]] - 1, deg[fa[u]]);
      ins(1, 1, n, id[u], 1LL * query(id[u]) * val[u] % MOD);
    } else
      printf("%lld\n", 1LL * query(1, 1, n, id[u], id[u] + size[u] - 1) *
                           qpow(query(id[fa[u]]), MOD - 2) % MOD);
  }
  return 0;
}