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 = 200005, Mod = 1e9 + 7;
int n, q, ts, A[N], D[N], P[N], Q[N], st[N], en[N];
int S[N * 4], Lz[N * 4];
vector<int> Adj[N];
inline int Power(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, a = 1ll * a * a % Mod)
    if (b & 1) ret = 1ll * ret * a % Mod;
  return (ret);
}
void DFS(int v) {
  st[v] = ts++;
  for (int &u : Adj[v]) DFS(u);
  en[v] = ts;
}
inline void Shift(int id) {
  if (Lz[id] == 1) return;
  Lz[(id + id)] = 1ll * Lz[(id + id)] * Lz[id] % Mod;
  Lz[(id + id + 1)] = 1ll * Lz[(id + id + 1)] * Lz[id] % Mod;
  S[(id + id)] = 1ll * S[(id + id)] * Lz[id] % Mod;
  S[(id + id + 1)] = 1ll * S[(id + id + 1)] * Lz[id] % Mod;
  Lz[id] = 1;
}
void Set(int i, int val, int id = 1, int l = 0, int r = ts) {
  if (r - l < 2) {
    S[id] = val;
    return;
  }
  Shift(id);
  if (i < ((l + r) >> 1))
    Set(i, val, (id + id), l, ((l + r) >> 1));
  else
    Set(i, val, (id + id + 1), ((l + r) >> 1), r);
  S[id] = (S[(id + id)] + S[(id + id + 1)]) % Mod;
}
void Mult(int le, int ri, int val, int id = 1, int l = 0, int r = ts) {
  if (ri <= l || r <= le) return;
  if (le <= l && r <= ri) {
    Lz[id] = 1ll * Lz[id] * val % Mod;
    S[id] = 1ll * S[id] * val % Mod;
    return;
  }
  Shift(id);
  Mult(le, ri, val, (id + id), l, ((l + r) >> 1));
  Mult(le, ri, val, (id + id + 1), ((l + r) >> 1), r);
  S[id] = (S[(id + id)] + S[(id + id + 1)]) % Mod;
}
int Get(int le, int ri, int id = 1, int l = 0, int r = ts) {
  if (ri <= l || r <= le) return (0);
  if (le <= l && r <= ri) return (S[id]);
  Shift(id);
  return ((Get(le, ri, (id + id), l, ((l + r) >> 1)) +
           Get(le, ri, (id + id + 1), ((l + r) >> 1), r)) %
          Mod);
}
int main() {
  scanf("%d%d", &A[++n], &q);
  for (int i = 1; i <= q; i++) {
    int t, p;
    scanf("%d%d", &t, &p);
    if (t == 1)
      scanf("%d", &A[++n]), P[n] = p, Q[i] = n, Adj[p].push_back(n);
    else
      Q[i] = -p;
  }
  DFS(1);
  memset(Lz, 1, sizeof(Lz));
  Set(st[1], A[1]);
  for (int i = 1; i <= q; i++) {
    int v = abs(Q[i]);
    if (Q[i] < 0) {
      if (v == 1)
        printf("%d\n", Get(st[v], en[v]));
      else
        printf("%lld\n", 1ll * Get(st[v], en[v]) *
                             Power(Get(st[P[v]], st[P[v]] + 1), Mod - 2) % Mod *
                             A[P[v]] % Mod);
    } else {
      int p = P[v], val = 1ll * Get(st[p], st[p] + 1) * Power(A[p], Mod - 2) %
                          Mod * A[v] % Mod;
      Set(st[v], val);
      D[p]++;
      Mult(st[p], en[p], (D[p] + 1) * 1ll * Power(D[p], Mod - 2) % Mod);
    }
  }
  return (0);
}