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 MAXN = 1e6 + 100;
const long long MOD = 1e9 + 7;
struct segment {
  long long seg[MAXN * 4], lazy[MAXN * 4];
  inline void shift(long long id) {
    lazy[2 * id + 1] = (lazy[2 * id + 1] * lazy[id]) % MOD;
    seg[2 * id + 1] = (seg[2 * id + 1] * lazy[id]) % MOD;
    lazy[2 * id + 2] = (lazy[2 * id + 2] * lazy[id]) % MOD;
    seg[2 * id + 2] = (seg[2 * id + 2] * lazy[id]) % MOD;
    lazy[id] = 1;
  }
  void mul_upd(long long ql, long long qr, long long qv, long long xl = 0,
               long long xr = MAXN, long long id = 0) {
    if (ql <= xl && xr <= qr) {
      lazy[id] = (lazy[id] * qv) % MOD;
      seg[id] = (seg[id] * qv) % MOD;
      return;
    }
    if (qr <= xl || xr <= ql) return;
    shift(id);
    long long mid = (xl + xr) / 2;
    mul_upd(ql, qr, qv, xl, mid, 2 * id + 1);
    mul_upd(ql, qr, qv, mid, xr, 2 * id + 2);
    seg[id] = (seg[2 * id + 1] + seg[2 * id + 2]) % MOD;
  }
  void add_upd(long long qp, long long qv, long long xl = 0,
               long long xr = MAXN, long long id = 0) {
    if (xl > qp || xr <= qp) return;
    if (xr - xl == 1) {
      seg[id] = (seg[id] + qv) % MOD;
      return;
    }
    shift(id);
    long long mid = (xl + xr) / 2;
    add_upd(qp, qv, xl, mid, 2 * id + 1);
    add_upd(qp, qv, mid, xr, 2 * id + 2);
    seg[id] = (seg[id] + qv) % MOD;
  }
  long long get(long long ql, long long qr, long long xl = 0,
                long long xr = MAXN, long long id = 0) {
    if (ql <= xl && xr <= qr) return seg[id];
    if (qr <= xl || xr <= ql) return 0;
    shift(id);
    long long mid = (xl + xr) / 2;
    return (get(ql, qr, xl, mid, 2 * id + 1) +
            get(ql, qr, mid, xr, 2 * id + 2)) %
           MOD;
  }
  void init() { fill(lazy, lazy + MAXN * 4, 1); }
};
long long power(long long a, long long b = MOD - 2) {
  if (!b) return 1;
  if (b % 2) return power(a, b - 1) * a % MOD;
  return power(a * a % MOD, b / 2);
}
vector<long long> ver[MAXN];
long long st[MAXN], fn[MAXN], T = 0;
void dfs(long long v) {
  st[v] = T++;
  for (auto u : ver[v]) dfs(u);
  fn[v] = T;
}
long long deg[MAXN];
segment A, B;
void add(long long v, long long w, long long par) {
  B.mul_upd(st[par], fn[par], power(deg[par] + 1));
  B.mul_upd(st[par], fn[par], deg[par] + 2);
  A.mul_upd(st[par], fn[par], power(deg[par] + 1));
  A.mul_upd(st[par], fn[par], deg[par] + 2);
  deg[par]++;
  A.add_upd(st[v], B.get(st[v], st[v] + 1) * w % MOD);
}
long long par[MAXN], v[MAXN], qu[MAXN], qt[MAXN];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long cnt = 0;
  cin >> v[cnt++];
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> qt[i];
    if (qt[i] == 1) {
      cin >> par[cnt] >> v[cnt];
      par[cnt]--;
      ver[par[cnt]].push_back(cnt);
      cnt++;
    } else {
      cin >> qu[i];
      qu[i]--;
    }
  }
  dfs(0);
  long long n = cnt;
  cnt = 1;
  A.init(), B.init();
  for (long long i = 0; i < n; i++) B.add_upd(i, 1);
  A.add_upd(0, v[0]);
  for (long long i = 0; i < q; i++) {
    if (qt[i] == 1) {
      add(cnt, v[cnt], par[cnt]);
      cnt++;
    } else {
      cout << A.get(st[qu[i]], fn[qu[i]]) *
                  power(
                      (qu[i] ? B.get(st[par[qu[i]]], st[par[qu[i]]] + 1) : 1)) %
                  MOD
           << '\n';
    }
  }
}