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;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return max(rm, 1ll);
}
const int N = 200009;
const int mod = 1000000007;
vector<int> edge[N];
long long int layer[4 * N + 1000], seg[4 * N + 1000] = {0};
int otype[N], p[N], t = 0, l[N], r[N], a[N], before[N] = {0}, rec[N], v[N],
                    u[N], v0[N] = {0};
void update0(int n, int it, int f, int q1, int q2, long long int val) {
  if (it == q1 && f == q2) {
    layer[n] = (layer[n] * val) % mod;
    if (it == f)
      seg[n] = 1ll * v0[a[f]] * layer[n];
    else
      seg[n] = (seg[n * 2] + seg[n * 2 + 1]) * layer[n];
    seg[n] %= mod;
    return;
  }
  int m = (it + f) / 2;
  if (q2 <= m)
    update0(n * 2, it, m, q1, q2, val);
  else if (q1 > m)
    update0(n * 2 + 1, m + 1, f, q1, q2, val);
  else {
    update0(n * 2, it, m, q1, m, val);
    update0(n * 2 + 1, m + 1, f, m + 1, q2, val);
  }
  seg[n] = (seg[n * 2] + seg[n * 2 + 1]) * layer[n];
  seg[n] %= mod;
}
void update1(int n, int it, int f, int q, long long int val) {
  if (it == f) {
    seg[n] = val * layer[n];
    seg[n] %= mod;
    return;
  }
  int m = (it + f) / 2;
  if (q <= m)
    update1(n * 2, it, m, q, val);
  else
    update1(n * 2 + 1, m + 1, f, q, val);
  seg[n] = (seg[n * 2] + seg[n * 2 + 1]) * layer[n];
  seg[n] %= mod;
}
long long int query(int n, int it, int f, int q1, int q2, long long int upper) {
  if (it == q1 && f == q2) {
    return (upper * seg[n]) % mod;
  }
  upper *= layer[n];
  upper %= mod;
  int m = (it + f) / 2;
  if (q2 <= m)
    return query(n * 2, it, m, q1, q2, upper);
  else if (q1 > m)
    return query(n * 2 + 1, m + 1, f, q1, q2, upper);
  else {
    long long int vvv1 = query(n * 2, it, m, q1, m, upper);
    vvv1 += query(n * 2 + 1, m + 1, f, m + 1, q2, upper);
    return vvv1 % mod;
  }
}
long long int query2(int n, int it, int f, int q, long long int prv) {
  prv *= layer[n];
  prv %= mod;
  if (it == f) return (prv * powmod(before[a[q]], mod - 2, mod)) % mod;
  int m = (it + f) / 2;
  if (q <= m)
    return query2(n * 2, it, m, q, prv);
  else
    return query2(n * 2 + 1, m + 1, f, q, prv);
}
void dfs(int vertex, int parent) {
  a[++t] = vertex;
  l[vertex] = t;
  for (int i = 0; i < edge[vertex].size(); ++i) {
    if (edge[vertex][i] != parent) {
      dfs(edge[vertex][i], vertex);
    }
  }
  r[vertex] = t;
}
int main() {
  int Q;
  int n = 1;
  long long int val, ans, ans2;
  cin >> v[1] >> Q;
  for (int i = int(1); i <= (int)Q; i++) {
    scanf("%d", &otype[i]);
    ;
    if (otype[i] == 1) {
      scanf("%d", &p[i]);
      ;
      scanf("%d", &val);
      ;
      ++n;
      edge[n].push_back(p[i]);
      edge[p[i]].push_back(n);
      rec[i] = n;
      v[n] = val;
    } else
      scanf("%d", &u[i]);
    ;
  }
  dfs(1, -1);
  for (int i = int(1); i <= (int)n; i++) before[i] = 1;
  fill(layer + 1, layer + 4 * N + 1, +1);
  update1(1, 1, n, l[1], v[1]);
  for (int i = int(1); i <= (int)Q; i++) {
    if (otype[i] == 1) {
      val = 1ll * (before[p[i]] + 1) * powmod(before[p[i]], mod - 2, mod);
      val %= mod;
      before[p[i]]++;
      if (val != 1) update0(1, 1, n, l[p[i]], r[p[i]], val);
      v0[rec[i]] = v[rec[i]];
      update1(1, 1, n, l[rec[i]], v[rec[i]]);
    } else {
      ans = query(1, 1, n, l[u[i]], r[u[i]], 1);
      ans2 = query2(1, 1, n, l[u[i]], 1);
      ans2 = powmod(ans2, mod - 2, mod);
      ans *= ans2;
      printf("%lld\n", ans % mod);
    }
  }
  return 0;
}