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 mod = 1e9 + 7;
int ksm(int x, int y = mod - 2) {
  int z = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) z = 1ll * z * x % mod;
  return z;
}
int n, a[200100], q, sz[200100], dfn[200100], rev[200100], tot, fa[200100],
    deg[200100];
struct SegTree {
  int sum, tag;
  SegTree() { sum = 0, tag = 1; }
} seg[800100];
void MUL(int x, int y) {
  seg[x].sum = 1ll * seg[x].sum * y % mod,
  seg[x].tag = 1ll * seg[x].tag * y % mod;
}
void pushdown(int x) {
  MUL(x << 1, seg[x].tag), MUL(x << 1 | 1, seg[x].tag), seg[x].tag = 1;
}
void pushup(int x) {
  seg[x].sum = (seg[x << 1].sum + seg[x << 1 | 1].sum) % mod;
}
void multiply(int x, int l, int r, int L, int R, int val) {
  if (l > R || r < L) return;
  if (L <= l && r <= R) {
    MUL(x, val);
    return;
  }
  pushdown(x), multiply(x << 1, l, ((l + r) >> 1), L, R, val),
      multiply(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R, val), pushup(x);
}
void turnon(int x, int l, int r, int P) {
  if (l > P || r < P) return;
  if (l == r) {
    seg[x].sum = 1ll * a[rev[P]] * seg[x].tag % mod;
    return;
  }
  pushdown(x), turnon(x << 1, l, ((l + r) >> 1), P),
      turnon(x << 1 | 1, ((l + r) >> 1) + 1, r, P), pushup(x);
}
int querytag(int x, int l, int r, int P) {
  if (l > P || r < P) return 0;
  if (l == r) return seg[x].tag;
  pushdown(x);
  return querytag(x << 1, l, ((l + r) >> 1), P) +
         querytag(x << 1 | 1, ((l + r) >> 1) + 1, r, P);
}
int querysum(int x, int l, int r, int L, int R) {
  if (l > R || r < L) return 0;
  if (L <= l && r <= R) return seg[x].sum;
  pushdown(x);
  return (querysum(x << 1, l, ((l + r) >> 1), L, R) +
          querysum(x << 1 | 1, ((l + r) >> 1) + 1, r, L, R)) %
         mod;
}
vector<int> v[200100];
int tp[200100], pos[200100];
void dfs(int x) {
  dfn[x] = ++tot, rev[tot] = x, sz[x] = 1;
  for (auto y : v[x]) fa[y] = x, dfs(y), sz[x] += sz[y];
}
int main() {
  scanf("%d%d", &a[n = 1], &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &tp[i], &pos[i]);
    if (tp[i] == 1) scanf("%d", &a[++n]), v[pos[i]].push_back(n), pos[i] = n;
  }
  for (int i = 1; i <= n; i++) deg[i] = 1;
  dfs(1), turnon(1, 1, n, 1);
  for (int i = 1, x; i <= q; i++) {
    if (tp[i] == 1) {
      x = fa[pos[i]];
      multiply(1, 1, n, dfn[x], dfn[x] + sz[x] - 1,
               1ll * (deg[x] + 1) * ksm(deg[x]) % mod),
          deg[x]++;
      turnon(1, 1, n, dfn[pos[i]]);
    } else
      x = pos[i],
      printf("%d\n", 1ll * querysum(1, 1, n, dfn[x], dfn[x] + sz[x] - 1) *
                         (x == 1 ? 1 : ksm(querytag(1, 1, n, dfn[fa[x]]))) %
                         mod);
  }
  return 0;
}