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;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 200010, mod = 1000000007;
struct edge {
  int v, nxt;
} e[N << 1];
int head[N], cnt, n, m, x, y, z, siz[N], fa[N], dep[N], son[N], seg[N], rev[N],
    top[N], d[N << 2], f[N << 2], sum[N << 2], ans1, ans2;
struct node {
  int x, y, opt;
} a[N];
inline int fpow(int x, int p) {
  int ans = 1;
  for (; p; p >>= 1, x = 1ll * x * x % mod)
    if (p & 1) ans = 1ll * ans * x % mod;
  return ans;
}
inline void add(int u, int v) {
  e[++cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
inline void dfs1(int u, int F) {
  dep[u] = dep[F] + 1;
  siz[u] = 1;
  fa[u] = F;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == F) continue;
    dfs1(v, u);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
inline void dfs2(int u, int F) {
  seg[u] = ++seg[0];
  rev[seg[0]] = u;
  top[u] = F;
  if (!son[u]) return;
  dfs2(son[u], F);
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == F || v == son[u]) continue;
    dfs2(v, v);
  }
}
inline void pushup(int p) { d[p] = 1ll * d[p << 1] * d[p << 1 | 1] % mod; }
inline void pushdown(int p) {
  if (f[p]) {
    int ls = p << 1, rs = p << 1 | 1;
    f[rs] = (f[rs] + f[p]) % mod;
    f[ls] = (f[ls] + 1ll * f[p] * d[rs] % mod) % mod;
    f[p] = 0;
  }
}
inline void change(int p, int l, int r, int x, int y) {
  if (l == r) {
    d[p] = (d[p] + 1) % mod;
    sum[p] = (sum[p] + y) % mod;
    return;
  }
  int mid = l + r >> 1, ls = p << 1, rs = p << 1 | 1;
  pushdown(p);
  if (x <= mid)
    change(ls, l, mid, x, y);
  else
    change(rs, mid + 1, r, x, y);
  pushup(p);
}
inline void query(int p, int l, int r, int x) {
  if (l == r) {
    ans1 = d[p];
    ans2 = (sum[p] + f[p]) % mod;
    return;
  }
  int mid = l + r >> 1, ls = p << 1, rs = p << 1 | 1;
  pushdown(p);
  if (x <= mid)
    query(ls, l, mid, x);
  else
    query(rs, mid + 1, r, x);
}
inline int Query(int p, int l, int r, int x, int y, int z) {
  if (x <= l && r <= y) {
    f[p] = (f[p] + z) % mod;
    return d[p];
  }
  int mid = l + r >> 1, ls = p << 1, rs = p << 1 | 1;
  pushdown(p);
  int ans = 1;
  if (y > mid) ans = 1ll * ans * Query(rs, mid + 1, r, x, y, z) % mod;
  if (x <= mid)
    ans = 1ll * ans * Query(ls, l, mid, x, y, 1ll * z * ans % mod) % mod;
  return ans;
}
inline void mian() {
  a[1].y = read();
  m = read();
  n = 1;
  for (int i = 1; i <= m; ++i) {
    a[i].opt = read();
    a[i].x = read();
    if (a[i].opt == 1) {
      ++n;
      a[n].y = read();
      add(a[i].x, n);
      a[i].x = n;
    }
  }
  dfs1(1, 0);
  dfs2(1, 1);
  change(1, 1, n, seg[1], a[1].y);
  for (int i = 1; i <= m; ++i) {
    if (a[i].opt == 1) {
      int p = a[i].x, cur = 1, num;
      change(1, 1, n, seg[p], a[p].y);
      ans1 = ans2 = 0;
      query(1, 1, n, seg[fa[p]]);
      change(1, 1, n, seg[fa[p]], a[p].y);
      num = ((1ll * ans1 * a[p].y % mod + ans2) % mod + a[p].y) % mod;
      for (int x = fa[fa[p]]; x; x = fa[top[x]])
        cur = 1ll * cur *
              Query(1, 1, n, seg[top[x]], seg[x], 1ll * num * cur % mod) % mod;
    } else {
      ans1 = ans2 = 0;
      query(1, 1, n, seg[a[i].x]);
      printf("%d\n", 1ll * ans1 * ans2 % mod);
    }
  }
}
int main() {
  int qwq = 1;
  while (qwq--) mian();
  return 0;
}