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;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
inline string get() {
  char ch[2000010];
  scanf("%s", ch);
  return ch;
}
inline void read(long long *a, long long n) {
  for (long long i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank>
inline void smin(blank &a, blank b) {
  a = min(a, b);
}
template <class blank>
inline void smax(blank &a, blank b) {
  a = max(a, b);
}
const long long maxn = 2e5 + 10;
const long long maxm = 1e6 + 10;
const long long maxlg = 21;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 10;
const long long SQ = 317;
long long v[maxn], father[maxn], tp[maxn],
    vertexcur = 1, cur = 0, start[maxn], finish[maxn], id[maxn],
    stree[4 * maxn], lazy[4 * maxn], deg[maxn];
vector<long long> g[maxn], Q;
inline void dfs(long long node) {
  start[node] = cur++;
  for (auto u : g[node]) dfs(u);
  finish[node] = cur - 1;
}
inline long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b % 2) ret = ret * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ret;
}
inline void shift(long long p) {
  lazy[2 * p + 1] = lazy[2 * p + 1] * lazy[p] % mod;
  lazy[2 * p + 2] = lazy[2 * p + 2] * lazy[p] % mod;
  stree[2 * p + 1] = stree[2 * p + 1] * lazy[p] % mod;
  stree[2 * p + 2] = stree[2 * p + 2] * lazy[p] % mod;
  lazy[p] = 1;
}
inline long long get(long long ql, long long qr, long long p = 0,
                     long long l = 0, long long r = cur - 1) {
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) return stree[p];
  long long mid = (l + r) >> 1;
  shift(p);
  return (get(ql, qr, 2 * p + 1, l, mid) + get(ql, qr, 2 * p + 2, mid + 1, r)) %
         mod;
}
inline void multiply(long long ql, long long qr, long long val, long long p = 0,
                     long long l = 0, long long r = cur - 1) {
  if (l > qr || r < ql || l > r) return;
  if (l >= ql && r <= qr) {
    lazy[p] = lazy[p] * val % mod;
    stree[p] = stree[p] * val % mod;
    return;
  }
  long long mid = (l + r) >> 1;
  shift(p);
  multiply(ql, qr, val, 2 * p + 1, l, mid),
      multiply(ql, qr, val, 2 * p + 2, mid + 1, r);
  stree[p] = (stree[2 * p + 1] + stree[2 * p + 2]) % mod;
}
inline void update(long long qx, long long val, long long p = 0,
                   long long l = 0, long long r = cur - 1) {
  if (l > qx || r < qx) return;
  if (l == r) {
    stree[p] = val;
    return;
  }
  long long mid = (l + r) >> 1;
  shift(p);
  update(qx, val, 2 * p + 1, l, mid);
  update(qx, val, 2 * p + 2, mid + 1, r);
  stree[p] = (stree[2 * p + 1] + stree[2 * p + 2]) % mod;
}
inline void add_vertex(long long node) {
  long long multiplyValue =
      (deg[father[node]] + 2) * power(deg[father[node]] + 1, mod - 2) % mod;
  if (node == 1) {
    update(0, v[node]);
    return;
  }
  deg[father[node]]++;
  multiply(start[father[node]], finish[father[node]], multiplyValue);
  long long contrib = get(start[father[node]], start[father[node]]) *
                      power(v[father[node]], mod - 2) % mod;
  update(start[node], contrib * v[node] % mod);
}
inline long long calc(long long node) {
  long long contrib =
      get(start[node], start[node]) * power(v[node], mod - 2) % mod;
  return get(start[node], finish[node]) * (deg[node] + 1) % mod *
         power(contrib, mod - 2) % mod;
}
int32_t main() {
  v[1] = in();
  long long q = in();
  memset(father, -1, sizeof father);
  fill(lazy, lazy + maxn, 1);
  for (long long i = 0; i < q; i++) {
    tp[i] = in();
    if (tp[i] == 1) {
      vertexcur++;
      father[vertexcur] = in();
      v[vertexcur] = in();
      g[father[vertexcur]].push_back(vertexcur);
      id[i] = vertexcur;
    } else
      Q.push_back(in());
  }
  dfs(1);
  add_vertex(1);
  long long Qcur = 0;
  for (long long i = 0; i < q; i++) {
    if (tp[i] == 1)
      add_vertex(id[i]);
    else
      cout << calc(Q[Qcur++]) << "\n";
  }
}