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 N = 2e5 + 7, mod = 1e9 + 7;
vector<long long> g[N], ord;
long long cnt, n = 1, q, val[N], st[N], ft[N], seg[4 * N], la[4 * N], deg[N];
long long tp[N], fi[N], se[N];
void dfs(long long x) {
  st[x] = cnt++;
  ord.push_back(x);
  for (auto i : g[x]) dfs(i);
  ft[x] = cnt;
}
long long pw(long long x, long long y) {
  if (!y) return 1ll;
  long long cnt = pw(x, y / 2);
  cnt = cnt * cnt % mod;
  if (y & 1) cnt = cnt * x % mod;
  return cnt;
}
void set_tag(long long tag) {
  seg[tag] = (seg[tag * 2] + seg[tag * 2 + 1]) % mod;
  seg[tag] = seg[tag] * la[tag] % mod;
}
void set_val(long long pos, long long tag = 1, long long s = 0,
             long long e = n) {
  if (e - s == 1) {
    seg[tag] = val[ord[s]] * la[tag] % mod;
    return;
  }
  long long mid = (s + e) / 2;
  if (pos < mid)
    set_val(pos, tag * 2, s, mid);
  else
    set_val(pos, tag * 2 + 1, mid, e);
  set_tag(tag);
}
void update(long long l, long long r, long long x, long long tag = 1,
            long long s = 0, long long e = n) {
  if (s >= l && e <= r) {
    la[tag] = la[tag] * x % mod;
    seg[tag] = seg[tag] * x % mod;
    return;
  }
  if (s >= r || e <= l) return;
  long long mid = (s + e) / 2;
  update(l, r, x, tag * 2, s, mid);
  update(l, r, x, tag * 2 + 1, mid, e);
  set_tag(tag);
}
long long get(long long l, long long r, long long tag = 1, long long s = 0,
              long long e = n) {
  if (s >= l && e <= r) return seg[tag];
  if (s >= r || e <= l) return 0;
  long long mid = (s + e) / 2;
  long long ans =
      (get(l, r, tag * 2, s, mid) + get(l, r, tag * 2 + 1, mid, e)) % mod;
  return (ans * la[tag] % mod);
}
long long real_power(long long x) {
  return (get(st[x], ft[x]) *
          pw((pw(val[x], mod - 2) * get(st[x], st[x] + 1)) % mod, mod - 2) %
          mod * deg[x] % mod);
}
int32_t main() {
  cin >> val[1] >> q;
  for (long long i = 0; i < q; i++) {
    cin >> tp[i] >> fi[i];
    if (tp[i] == 1) {
      cin >> se[i];
      val[++n] = se[i];
      g[fi[i]].push_back(n);
    }
  }
  dfs(1);
  fill(la, la + N * 4, 1);
  set_val(st[1]);
  deg[1] = 1;
  long long cn = 1;
  for (long long i = 0; i < q; i++) {
    if (tp[i] == 1) {
      cn++;
      long long x = fi[i];
      set_val(st[cn]);
      update(st[x], ft[x], pw(deg[x], mod - 2));
      deg[x]++, deg[cn]++;
      update(st[x], ft[x], deg[x]);
    } else
      cout << real_power(fi[i]) << endl;
    ;
  }
}