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 P = 1e9 + 7;
int n, m, q;
int A[200006];
int Pow(int x, int a) {
  int ret = 1;
  while (a) {
    if (a & 1) ret = ret * 1ll * x % P;
    a >>= 1, x = x * 1ll * x % P;
  }
  return ret;
}
struct que {
  int o, x;
} Q[200006];
vector<int> G[200006];
int L[200006], R[200006], clo, siz[200006], fa[200006], dep[200006], bc[200006];
void dfs(int u) {
  L[u] = ++clo;
  bc[clo] = u;
  for (int v : G[u]) {
    dep[v] = dep[u] * 1ll * A[v] % P;
    dfs(v);
  }
  R[u] = clo;
}
int T[200006 << 2], F[200006 << 2], lz[200006 << 2];
void pu(int rt) { T[rt] = (T[rt << 1] + T[rt << 1 | 1]) % P; }
void mul(int rt, int c) {
  if (F[rt]) F[rt] = F[rt] * 1ll * c % P;
  T[rt] = T[rt] * 1ll * c % P;
  lz[rt] = lz[rt] * 1ll * c % P;
}
void pd(int rt) {
  if (lz[rt] != 1) {
    mul(rt << 1, lz[rt]), mul(rt << 1 | 1, lz[rt]);
    lz[rt] = 1;
  }
}
void build(int rt, int l, int r) {
  lz[rt] = 1;
  if (l == r) {
    F[rt] = 1;
    T[rt] = (l == 1 ? A[1] : 0);
    return;
  }
  int m = l + r >> 1;
  build(rt << 1, l, m), build(rt << 1 | 1, m + 1, r);
  pu(rt);
}
void mul(int rt, int l, int r, int L, int R, int c) {
  if (L <= l && R >= r) {
    mul(rt, c);
    return;
  }
  pd(rt);
  int m = l + r >> 1;
  if (L <= m) mul(rt << 1, l, m, L, R, c);
  if (R > m) mul(rt << 1 | 1, m + 1, r, L, R, c);
  pu(rt);
}
int wkr(int rt, int l, int r, int L, int R) {
  if (L <= l && R >= r) return T[rt];
  pd(rt);
  int m = l + r >> 1, as = 0;
  if (L <= m) as = wkr(rt << 1, l, m, L, R);
  if (R > m) as = (as + wkr(rt << 1 | 1, m + 1, r, L, R)) % P;
  return as;
}
void lsj(int rt, int l, int r, int p) {
  if (l == r) {
    T[rt] = F[rt] * 1ll * A[bc[p]] % P;
    return;
  }
  pd(rt);
  int m = l + r >> 1;
  if (p <= m)
    lsj(rt << 1, l, m, p);
  else
    lsj(rt << 1 | 1, m + 1, r, p);
  pu(rt);
}
int qp(int rt, int l, int r, int p) {
  if (l == r) return F[rt];
  pd(rt);
  int m = l + r >> 1;
  if (p <= m) return qp(rt << 1, l, m, p);
  return qp(rt << 1 | 1, m + 1, r, p);
}
int deg[200006];
void solve() {
  cin >> A[1] >> q;
  n = 1;
  for (int i = (1), iend = (q); i <= iend; ++i) {
    int op, p;
    scanf("%d%d", &op, &p);
    if (op == 1)
      ++n, scanf("%d", A + n), fa[n] = p, Q[i] = (que){op, n},
                               G[p].push_back(n);
    else
      Q[i] = (que){0, p};
  }
  dep[1] = 1, dfs(1);
  build(1, 1, n);
  for (int i = (1), iend = (n); i <= iend; ++i) deg[i] = 1;
  for (int i = (1), iend = (q); i <= iend; ++i) {
    int o = Q[i].o, u = Q[i].x, f = fa[u];
    if (o) {
      int ml = (deg[f] + 1) * 1ll * Pow(deg[f], P - 2) % P;
      mul(1, 1, n, L[f], R[f], ml);
      lsj(1, 1, n, L[u]);
      ++deg[f];
    } else {
      printf("%lld\n", wkr(1, 1, n, L[u], R[u]) * 1ll *
                           (u != 1 ? Pow(qp(1, 1, n, L[fa[u]]), P - 2) : 1) %
                           P);
    }
  }
}
signed main() { solve(); }