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 = 2e5 + 5, P = 1e9 + 7;
int n = 1, w0, q, op[N], u[N], w[N];
vector<int> G[N];
int idx, fa[N], dfn[N], suf[N], d[N];
long long Pow(long long a, int n, long long r = 1) {
  for (; n; n /= 2, a = a * a % P)
    if (n & 1) r = r * a % P;
  return r;
}
void dfs(int u) {
  dfn[u] = ++idx;
  for (int v : G[u]) dfs(v);
  suf[u] = idx;
}
long long c[N * 4], tag[N * 4];
void put(int o, long long v) { (c[o] *= v) %= P, (tag[o] *= v) %= P; }
void pushdown(int o) {
  if (tag[o] ^ 1) put(o * 2, tag[o]), put(o * 2 + 1, tag[o]), tag[o] = 1;
}
void pushup(int o) { c[o] = (c[o * 2] + c[o * 2 + 1]) % P; }
void upd(int L, int R, long long v, int l, int r, int o) {
  if (L <= l && r <= R) return put(o, v);
  pushdown(o);
  if (L <= (l + r) / 2) upd(L, R, v, l, (l + r) / 2, o * 2);
  if (R > (l + r) / 2) upd(L, R, v, (l + r) / 2 + 1, r, o * 2 + 1);
  pushup(o);
}
void add(int p, long long v, int l, int r, int o) {
  if (l == r) return c[o] = v, void();
  pushdown(o);
  if (p <= (l + r) / 2)
    add(p, v, l, (l + r) / 2, o * 2);
  else
    add(p, v, (l + r) / 2 + 1, r, o * 2 + 1);
  pushup(o);
}
int qry(int L, int R, int l, int r, int o) {
  if (L <= l && r <= R) return c[o];
  int res = 0;
  pushdown(o);
  if (L <= (l + r) / 2) res += qry(L, R, l, (l + r) / 2, o * 2);
  if (R > (l + r) / 2) res += qry(L, R, (l + r) / 2 + 1, r, o * 2 + 1);
  return res % P;
}
int qry(int p, int l, int r, int o) {
  if (l == r) return tag[o];
  pushdown(o);
  return p <= (l + r) / 2 ? qry(p, l, (l + r) / 2, o * 2)
                          : qry(p, (l + r) / 2 + 1, r, o * 2 + 1);
}
int main() {
  cin >> w[1] >> q;
  for (int i = (1); i <= (q); i++) {
    scanf("%d%d", &op[i], &u[i]);
    if (op[i] == 1) scanf("%d", &w[++n]), G[fa[n] = u[i]].push_back(n);
  }
  dfs(1);
  int sz = 1;
  for (int i = (1); i <= (n * 4); i++) tag[i] = 1;
  for (int i = (1); i <= (n); i++) d[i] = 1;
  add(1, w[1], 1, n, 1);
  for (int i = (1); i <= (q); i++) {
    int o = u[i];
    if (op[i] == 1) {
      sz++, add(dfn[sz], 1LL * w[sz] * qry(dfn[o], 1, n, 1) % P, 1, n, 1);
      upd(dfn[o], suf[o], (d[o] + 1) * Pow(d[o], P - 2) % P, 1, n, 1), d[o]++;
    } else
      printf("%lld\n",
             qry(dfn[o], suf[o], 1, n, 1) *
                 (o > 1 ? Pow(qry(dfn[fa[o]], 1, n, 1), P - 2) : 1LL) % P);
  }
  return 0;
}