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 long long mod = 1e9 + 7, maxn = 2e5 + 79;
long long pwr(long long a, long long b) {
  if (!b) return 1;
  long long h = pwr(a, b >> 1);
  return (((h * h) % mod) * ((b & 1ll) ? a : 1)) % mod;
}
vector<long long> val(maxn * 2, 0);
class segment_tree_multiply_sum_point_update {
  vector<long long> lazy, c, s;
  vector<int> l, r;
  void unlazy(int v) {
    c[v * 2 + 1] = (c[v * 2 + 1] * c[v]) % mod;
    c[v * 2 + 2] = (c[v * 2 + 2] * c[v]) % mod;
    s[v * 2 + 1] = (s[v * 2 + 1] * lazy[v]) % mod;
    s[v * 2 + 2] = (s[v * 2 + 2] * lazy[v]) % mod;
    lazy[v * 2 + 1] = (lazy[v * 2 + 1] * lazy[v]) % mod;
    lazy[v * 2 + 2] = (lazy[v * 2 + 2] * lazy[v]) % mod;
    lazy[v] = c[v] = 1;
  }

 public:
  segment_tree_multiply_sum_point_update(int n) {
    int n2 = 1;
    while (n2 < n) n2 <<= 1;
    lazy.resize(n2 * 2, 1);
    c.resize(n2 * 2, 1);
    s.resize(n2 * 2, 0);
    l.resize(n2 * 2);
    r.resize(n2 * 2);
    for (int i = n2 - 1; i < n2 * 2; i++) l[i] = r[i] = i - (n2 - 1);
    for (int i = n2 - 2; i >= 0; i--) {
      l[i] = l[i * 2 + 1];
      r[i] = r[i * 2 + 2];
    }
  }
  long long sum(int li, int ri, int v = 0) {
    if (ri < l[v] || r[v] < li) return 0;
    if (li <= l[v] && r[v] <= ri) return s[v];
    unlazy(v);
    return (sum(li, ri, v * 2 + 1) + sum(li, ri, v * 2 + 2)) % mod;
  }
  void multiply(int li, int ri, long long m, int v = 0) {
    if (ri < l[v] || r[v] < li) return;
    if (li <= l[v] && r[v] <= ri) {
      c[v] = (c[v] * m) % mod;
      lazy[v] = (lazy[v] * m) % mod;
      s[v] = (s[v] * m) % mod;
      return;
    }
    unlazy(v);
    multiply(li, ri, m, v * 2 + 1);
    multiply(li, ri, m, v * 2 + 2);
    s[v] = (s[v * 2 + 1] + s[v * 2 + 2]) % mod;
  }
  void assign(int i, long long d, int v = 0) {
    if (i == l[v] && r[v] == i) {
      c[v] = d;
      s[v] = (c[v] * val[v - (l.size() / 2 - 1)]) % mod;
    } else {
      unlazy(v);
      assign(i, d, i <= r[v * 2 + 1] ? v * 2 + 1 : v * 2 + 2);
      s[v] = (s[v * 2 + 1] + s[v * 2 + 2]) % mod;
    }
  }
  long long get(int i, int v = 0) {
    if (v * 2 + 2 < l.size()) unlazy(v);
    return ((v * 2 + 1 < r.size()
                 ? get(i, i <= r[v * 2 + 1] ? v * 2 + 1 : v * 2 + 2)
                 : 1ll) *
            c[v]) %
           mod;
  }
};
int timer = 0;
vector<int> tin(maxn), tout(maxn);
vector<long long> d(maxn, 0);
vector<vector<int> > son(maxn);
void dfs(int v) {
  tin[v] = timer++;
  for (int i : son[v]) dfs(i);
  tout[v] = timer - 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q, n = 1, c;
  cin >> c >> q;
  val[0] = c;
  vector<array<long long, 3> > qr(q);
  for (int i = 0; i < q; i++) {
    cin >> qr[i][0] >> qr[i][1];
    qr[i][1]--;
    if (qr[i][0] == 1) {
      cin >> qr[i][2];
      son[qr[i][1]].push_back(n++);
    }
  }
  dfs(0);
  segment_tree_multiply_sum_point_update st(n);
  st.assign(tin[0], 1);
  int n2 = 1;
  for (int i = 0; i < q; i++) {
    if (qr[i][0] == 1) {
      st.multiply(
          tin[qr[i][1]], tout[qr[i][1]],
          ((d[qr[i][1]] + 2ll) * pwr(d[qr[i][1]] + 1ll, mod - 2)) % mod);
      val[tin[n2]] = qr[i][2];
      st.assign(tin[n2], st.get(tin[qr[i][1]]));
      d[qr[i][1]]++;
      n2++;
    } else {
      long long c =
          ((d[qr[i][1]] + 1ll) * pwr(st.get(tin[qr[i][1]]), mod - 2)) % mod;
      cout << (st.sum(tin[qr[i][1]], tout[qr[i][1]]) * c) % mod << "\n";
    }
  }
  return 0;
}