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;
const int Mod = 1e9 + 7;
int n = 1, q;
int ord, in[N], out[N];
int v[N], opt[N], p[N], u[N], deg[N];
vector<int> E[N];
void dfs(int x) {
  in[x] = ++ord;
  for (int &i : E[x]) dfs(i);
  out[x] = ord;
}
inline int Pow(int a, int x) {
  int res = 1;
  while (x) {
    if (x & 1) res = (long long)res * a % Mod;
    a = (long long)a * a % Mod;
    x >>= 1;
  }
  return res;
}
long long sum[N << 2], w[N << 2];
long long lazy[N << 2];
int inv[N];
inline void pushdown(int &k) {
  if (!lazy[k]) return;
  if (lazy[k << 1])
    lazy[k << 1] = lazy[k << 1] * lazy[k] % Mod;
  else
    lazy[k << 1] = lazy[k];
  if (lazy[k << 1 | 1])
    lazy[k << 1 | 1] = lazy[k << 1 | 1] * lazy[k] % Mod;
  else
    lazy[k << 1 | 1] = lazy[k];
  sum[k << 1] = sum[k << 1] * lazy[k] % Mod;
  sum[k << 1 | 1] = sum[k << 1 | 1] * lazy[k] % Mod;
  w[k << 1] = w[k << 1] * lazy[k] % Mod;
  w[k << 1 | 1] = w[k << 1 | 1] * lazy[k] % Mod;
  lazy[k] = 0;
}
void Ins(int k, int l, int r, int p, int v, int v1) {
  if (l != r) pushdown(k);
  if (l == r) {
    sum[k] = v;
    w[k] = v1;
    return;
  }
  int mid = l + r >> 1;
  if (p <= mid)
    Ins(k << 1, l, mid, p, v, v1);
  else
    Ins(k << 1 | 1, mid + 1, r, p, v, v1);
  sum[k] = (sum[k << 1] + sum[k << 1 | 1]) % Mod;
}
void modify(int k, int l, int r, int p, int q, int v) {
  if (l != r) pushdown(k);
  if (l > q || r < p) return;
  if (l >= p && r <= q) {
    lazy[k] = v;
    sum[k] = sum[k] * v % Mod;
    w[k] = w[k] * v % Mod;
    return;
  }
  int mid = l + r >> 1;
  modify(k << 1, l, mid, p, q, v);
  modify(k << 1 | 1, mid + 1, r, p, q, v);
  sum[k] = (sum[k << 1] + sum[k << 1 | 1]) % Mod;
}
int Queryw(int k, int l, int r, int p) {
  if (l != r) pushdown(k);
  if (l == r) return w[k];
  int mid = l + r >> 1;
  if (p <= mid) return Queryw(k << 1, l, mid, p);
  return Queryw(k << 1 | 1, mid + 1, r, p);
}
int Querys(int k, int l, int r, int p, int q) {
  if (l != r) pushdown(k);
  if (l > q || r < p) return 0;
  if (l >= p && r <= q) return sum[k];
  int mid = l + r >> 1;
  return (Querys(k << 1, l, mid, p, q) + Querys(k << 1 | 1, mid + 1, r, p, q)) %
         Mod;
}
int main() {
  inv[0] = inv[1] = 1;
  for (int i = 2; i < N; i++)
    inv[i] = (long long)(Mod - Mod / i) * inv[Mod % i] % Mod;
  scanf("%d%d", v + 1, &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", opt + i);
    if (opt[i] == 1) {
      n++;
      u[i] = n;
      scanf("%d%d", p + n, v + n);
      E[p[n]].push_back(n);
    } else {
      scanf("%d", u + i);
    }
  }
  dfs(1);
  Ins(1, 1, n, 1, v[1], 1);
  deg[1] = 1;
  for (int i = 1; i <= q; i++) {
    if (opt[i] == 1) {
      modify(1, 1, n, in[p[u[i]]], out[p[u[i]]],
             (long long)inv[deg[p[u[i]]]] * (deg[p[u[i]]] + 1) % Mod);
      deg[p[u[i]]]++;
      deg[u[i]] = 1;
      int W = Queryw(1, 1, n, in[p[u[i]]]);
      Ins(1, 1, n, in[u[i]], (long long)W * v[u[i]] % Mod, W);
    } else {
      int W = u[i] == 1 ? 1 : Queryw(1, 1, n, in[p[u[i]]]);
      int ans = (long long)Pow(W, Mod - 2) *
                Querys(1, 1, n, in[u[i]], out[u[i]]) % Mod;
      printf("%d\n", ans);
    }
  }
}