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 int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 2e5 + 10;
const long long MOD = 1e9 + 7;
const long double eps = 1e-12;
int n, q[N], ind, st[N], ft[N], qnum, cnt, par[N], deg[N], vall[N];
int dep[4 * N];
bool w[N];
int added[N];
int seg[4 * N], mul[4 * N], val[N];
vector<int> e[N];
long long bpow(long long x) {
  long long ret = 1;
  long long y = MOD - 2;
  x %= MOD;
  while (y > 0) {
    if (y % 2) ret = (ret * x) % MOD;
    ret %= MOD;
    y /= 2;
    x = (x * x) % MOD;
  }
  return (ret + MOD) % MOD;
}
void dfs(int v) {
  st[v] = cnt++;
  for (int i = 0; i < e[v].size(); i++) dfs(e[v][i]);
  ft[v] = cnt;
}
void shifit(int idx) {
  mul[idx * 2 + 0] = (1LL * mul[idx * 2 + 0] * mul[idx]) % MOD;
  mul[idx * 2 + 1] = (1LL * mul[idx * 2 + 1] * mul[idx]) % MOD;
  seg[idx * 2 + 0] = (1LL * seg[idx * 2 + 0] * mul[idx]) % MOD;
  seg[idx * 2 + 1] = (1LL * seg[idx * 2 + 1] * mul[idx]) % MOD;
  mul[idx] = 1;
}
void build(int l = 0, int r = n, int idx = 1) {
  dep[idx] = 1;
  if (r - l < 2) {
    seg[idx] = val[l];
    return;
  }
  int mid = (l + r) / 2;
  build(l, mid, idx * 2 + 0);
  build(mid, r, idx * 2 + 1);
}
int add(int id, int l = 0, int r = n, int idx = 1) {
  if (id >= r || id < l) {
    if (r - l < 2) return (added[l] ? seg[idx] : 0);
    return seg[idx];
  }
  if (r - l < 2) return seg[idx];
  shifit(idx);
  int mid = (l + r) / 2;
  seg[idx] = add(id, l, mid, idx * 2 + 0);
  seg[idx] += add(id, mid, r, idx * 2 + 1);
  seg[idx] = seg[idx] % MOD;
  return seg[idx];
}
int upd(int val, int ql, int qr, int l = 0, int r = n, int idx = 1) {
  if (qr <= l || r <= ql) {
    if (r - l < 2) return seg[idx] * added[l];
    return seg[idx];
  }
  if (ql <= l && r <= qr) {
    dep[idx] = (1LL * val * dep[idx]) % MOD;
    mul[idx] = (1LL * val * mul[idx]) % MOD;
    seg[idx] = (1LL * val * seg[idx]) % MOD;
    if (r - l < 2) return seg[idx] * added[l];
    return seg[idx];
  }
  shifit(idx);
  int mid = (l + r) / 2;
  seg[idx] = upd(val, ql, qr, l, mid, idx * 2 + 0);
  seg[idx] += upd(val, ql, qr, mid, r, idx * 2 + 1);
  seg[idx] = seg[idx] % MOD;
  return seg[idx];
}
int get(int ql, int qr, int l = 0, int r = n, int idx = 1) {
  if (qr <= l || r <= ql) return 0;
  if (ql <= l && r <= qr) {
    if (r - l < 2) return seg[idx] * added[l];
    return seg[idx];
  }
  shifit(idx);
  int mid = (l + r) / 2;
  return (get(ql, qr, l, mid, idx * 2 + 0) + get(ql, qr, mid, r, idx * 2 + 1)) %
         MOD;
}
int getDep(int id, int l = 0, int r = n, int idx = 1) {
  if (id >= r || id < l) return 1;
  if (r - l < 2) return dep[idx];
  int m = (l + r) / 2;
  long long res = dep[idx];
  res = (res * 1LL * getDep(id, l, m, idx * 2 + 0)) % MOD;
  res = (res * 1LL * getDep(id, m, r, idx * 2 + 1)) % MOD;
  return res % MOD;
}
int main() {
  for (int i = 0; i < 4 * N; i++) mul[i] = 1;
  for (int i = 0; i < N; i++) deg[i] = 1;
  vall[0] = in();
  n = in();
  ind = 1;
  qnum = n;
  for (int i = 1; i <= n; i++) {
    short int k = in();
    k--;
    w[i] = k;
    if (w[i])
      q[i] = in(), q[i]--;
    else {
      int p = in();
      p--;
      par[ind] = p;
      e[p].push_back(ind);
      vall[ind] = in();
      q[i] = ind;
      ind++;
    }
  }
  dfs(0);
  n = ind;
  added[st[0]] = 1;
  for (int i = 0; i < n; i++) val[st[i]] = vall[i];
  build();
  add(st[0]);
  for (int i = 1; i <= qnum; i++) {
    if (w[i]) {
      int v = q[i];
      int qq = (1LL * get(st[v], ft[v]) * bpow(getDep(st[v]))) % MOD;
      cout << (1LL * qq * deg[v]) % MOD << "\n";
    } else {
      int v = q[i];
      added[st[v]] = 1;
      add(st[v]);
      int p = par[v];
      upd(bpow(deg[p]), st[p], ft[p]);
      deg[p]++;
      upd(deg[p], st[p], ft[p]);
    }
  }
  return 0;
}