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 int N = 2e5 + 100, MOD = 1000 * 1000 * 1000 + 7;
int sum(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
void _sum(int &a, int b) { a = sum(a, b); }
int mul(int a, int b) { return 1LL * a * b % MOD; }
void _mul(int &a, int b) { a = mul(a, b); }
int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) _mul(res, a);
    _mul(a, a);
    b >>= 1;
  }
  return res;
}
int inv(int x) { return power(x, MOD - 2); }
int q, n, T, d[N], type[N], par[N], v[N], val[N], l[N], r[N];
vector<int> child[N];
struct node {
  int sum, lazy;
  node() { lazy = 1; }
  void MUL(int x) {
    _mul(lazy, x);
    _mul(sum, x);
  }
};
struct segment {
  node seg[N << 2];
  void updc(int v, int lc, int rc) {
    seg[lc].MUL(seg[v].lazy);
    seg[rc].MUL(seg[v].lazy);
    seg[v].lazy = 1;
  }
  int get(int l, int r, int v = 1, int s = 0, int e = N) {
    if (r <= s || e <= l) return 0;
    if (l <= s && e <= r) return seg[v].sum;
    int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
    updc(v, lc, rc);
    return sum(get(l, r, lc, s, mid), get(l, r, rc, mid, e));
  }
  void change(int dex, int val, int v = 1, int s = 0, int e = N) {
    if (dex < s || e <= dex) return;
    if (e - s == 1) {
      seg[v].sum = val;
      return;
    }
    int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
    updc(v, lc, rc);
    change(dex, val, lc, s, mid);
    change(dex, val, rc, mid, e);
    seg[v].sum = sum(seg[lc].sum, seg[rc].sum);
  }
  void mul(int l, int r, int val, int v = 1, int s = 0, int e = N) {
    if (r <= s || e <= l) return;
    if (l <= s && e <= r) {
      seg[v].MUL(val);
      return;
    }
    int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
    updc(v, lc, rc);
    mul(l, r, val, lc, s, mid);
    mul(l, r, val, rc, mid, e);
    seg[v].sum = sum(seg[lc].sum, seg[rc].sum);
  }
} tree;
void dfs(int v = 0) {
  l[v] = T++;
  for (int u : child[v]) dfs(u);
  r[v] = T;
}
void input_ready() {
  cin >> val[0] >> q;
  val[0];
  n++;
  for (int i = 0; i < q; i++) {
    cin >> type[i];
    if (type[i] == 1) {
      cin >> par[n] >> val[n];
      child[--par[n]].push_back(n);
      n++;
    } else {
      cin >> v[i];
      v[i]--;
    }
  }
  dfs();
}
int Z(int v) { return mul(tree.get(l[v], l[v] + 1), inv(val[v])); }
void solve() {
  n = 1;
  tree.change(l[0], val[0]);
  for (int i = 0; i < q; i++)
    if (type[i] == 1) {
      tree.mul(l[par[n]], r[par[n]], mul(inv(d[par[n]] + 1), d[par[n]] + 2));
      tree.change(l[n], mul(val[n], Z(par[n])));
      d[par[n]]++;
      n++;
    } else
      cout << mul(tree.get(l[v[i]], r[v[i]]), inv(v[i] == 0 ? 1 : Z(par[v[i]])))
           << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input_ready();
  solve();
}