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 int md = 1e9 + 7;
const int MAXN = 2e5 + 5;
int q, n = 0, st[MAXN], ft[MAXN], tim = 0, par[MAXN], x[MAXN], ty[MAXN];
long long int w[MAXN], cnt[MAXN], k[MAXN * 4], cont[MAXN * 4], lazy[MAXN * 4];
vector<int> adj[MAXN];
void dfs(int v, int parv) {
  st[v] = tim;
  tim++;
  for (auto u : adj[v])
    if (u != parv) dfs(u, v);
  ft[v] = tim;
  return;
}
long long int inv(long long int a, long long int b = 1e9 + 5) {
  if (b == 0) return 1ll;
  long long int k = inv(a, b / 2);
  k *= k;
  k %= md;
  if (b % 2ll) k *= a;
  k %= md;
  return k;
}
void upd(int ind) {
  cont[ind * 2] *= lazy[ind];
  cont[ind * 2] %= md;
  cont[ind * 2 + 1] *= lazy[ind];
  cont[ind * 2 + 1] %= md;
  k[ind * 2] *= lazy[ind];
  k[ind * 2] %= md;
  k[ind * 2 + 1] *= lazy[ind];
  k[ind * 2 + 1] %= md;
  lazy[ind * 2] *= lazy[ind];
  lazy[ind * 2] %= md;
  lazy[ind * 2 + 1] *= lazy[ind];
  lazy[ind * 2 + 1] %= md;
  lazy[ind] = 1ll;
  return;
}
void up(int ind) {
  cont[ind] = (cont[ind * 2] + cont[ind * 2 + 1]) % md;
  return;
}
void turnon(long long int ww, int x, int b = 0, int e = n, int ind = 1) {
  if (b + 1 == e) {
    cont[ind] = ww;
    return;
  }
  upd(ind);
  int mid = (b + e) / 2;
  if (x < mid)
    turnon(ww, x, b, mid, ind * 2);
  else
    turnon(ww, x, mid, e, ind * 2 + 1);
  up(ind);
  return;
}
long long int getk(int x, int b = 0, int e = n, int ind = 1) {
  if (b + 1 == e) return k[ind];
  int mid = (b + e) / 2;
  long long int ret;
  upd(ind);
  if (x < mid)
    ret = getk(x, b, mid, ind * 2);
  else
    ret = getk(x, mid, e, ind * 2 + 1);
  up(ind);
  return ret;
}
void mul(long long int val, int l, int r, int b = 0, int e = n, int ind = 1) {
  if (r <= b || e <= l) return;
  if (l <= b && r >= e) {
    k[ind] *= val;
    k[ind] %= md;
    cont[ind] *= val;
    cont[ind] %= md;
    lazy[ind] *= val;
    lazy[ind] %= md;
    return;
  }
  upd(ind);
  int mid = (b + e) / 2;
  mul(val, l, r, b, mid, ind * 2);
  mul(val, l, r, mid, e, ind * 2 + 1);
  up(ind);
  return;
}
long long int getcont(int l, int r, int b = 0, int e = n, int ind = 1) {
  if (r <= b || e <= l) return 0ll;
  if (l <= b && r >= e) return cont[ind];
  upd(ind);
  int mid = (b + e) / 2;
  long long int ret = 0ll;
  ret = (ret + getcont(l, r, b, mid, ind * 2)) % md;
  ret = (ret + getcont(l, r, mid, e, ind * 2 + 1)) % md;
  up(ind);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < MAXN * 4; i++) lazy[i] = 1ll, k[i] = 1ll;
  for (int i = 0; i < MAXN; i++) cnt[i] = 1ll;
  cin >> w[0] >> q;
  n = 1;
  par[0] = -1;
  for (int i = 0; i < q; i++) {
    cin >> ty[i];
    if (ty[i] == 1) {
      x[i] = n;
      cin >> par[n] >> w[n];
      par[n]--;
      adj[par[n]].push_back(n);
      n++;
    } else {
      cin >> x[i];
      x[i]--;
    }
  }
  dfs(0, -1);
  turnon(w[0], st[0]);
  for (int i = 0; i < q; i++) {
    int v = x[i];
    if (ty[i] == 2) {
      long long int k2 = 1ll;
      if (v != 0) k2 = getk(st[par[v]]);
      k2 = inv(k2);
      k2 *= getcont(st[v], ft[v]);
      k2 %= md;
      cout << k2 << '\n';
    } else {
      long long int ww = getk(st[par[v]]);
      ww *= w[v];
      ww %= md;
      turnon(ww, st[v]);
      ww = (cnt[par[v]] + 1ll) * inv(cnt[par[v]]);
      ww %= md;
      cnt[par[v]]++;
      mul(ww, st[par[v]], ft[par[v]]);
    }
  }
  return 0;
}