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 MX = 300000, md = 1000000007;
struct {
  int l, r, lSon, rSon, mult, sum;
} t[4 * MX];
vector<int> G[MX];
int pos[MX], last[MX];
long long ololo(long long x, int p) {
  long long r = 1;
  while (p) {
    if (p % 2) r = (r * x) % md;
    x = (x * x) % md;
    p /= 2;
  }
  return r;
}
void dfs(int v) {
  static int t = 0;
  pos[v] = t++;
  for (int u : G[v]) dfs(u);
  last[v] = t - 1;
}
int build_tree(int l, int r) {
  static int tw = 0;
  int v = ++tw;
  t[v].l = l;
  t[v].r = r;
  t[v].mult = 1;
  t[v].sum = 0;
  if (l < r) {
    t[v].lSon = build_tree(l, (l + r) / 2);
    t[v].rSon = build_tree((l + r) / 2 + 1, r);
  }
  return v;
}
void add(int v, int x, int delta) {
  if (t[v].l == t[v].r) {
    t[v].sum = t[v].mult * 1ll * delta % md;
    return;
  }
  if (x <= t[t[v].lSon].r)
    add(t[v].lSon, x, delta);
  else
    add(t[v].rSon, x, delta);
  t[v].sum = t[v].mult * 1ll * (t[t[v].lSon].sum + t[t[v].rSon].sum) % md;
}
void mult(int v, int l, int r, int p) {
  if (l <= t[v].l && t[v].r <= r) {
    t[v].mult = (t[v].mult * 1ll * p) % md;
    t[v].sum = (t[v].sum * 1ll * p) % md;
    return;
  }
  if (t[t[v].lSon].r >= l) mult(t[v].lSon, l, r, p);
  if (t[t[v].rSon].l <= r) mult(t[v].rSon, l, r, p);
  t[v].sum = t[v].mult * 1ll * (t[t[v].lSon].sum + t[t[v].rSon].sum) % md;
}
int query(int v, int l, int r) {
  if (l <= t[v].l && t[v].r <= r) return t[v].sum;
  int res = 0;
  if (t[t[v].lSon].r >= l) res += query(t[v].lSon, l, r);
  if (t[t[v].rSon].l <= r) res += query(t[v].rSon, l, r);
  return t[v].mult * 1ll * res % md;
}
int prod(int v, int x) {
  if (t[v].l == t[v].r) return t[v].mult;
  if (x <= t[t[v].lSon].r)
    return t[v].mult * 1ll * prod(t[v].lSon, x) % md;
  else
    return t[v].mult * 1ll * prod(t[v].rSon, x) % md;
}
int T[MX], p[MX], v[MX], s[MX], inv[MX];
int main() {
  int v1, q, n = 1;
  scanf("%d %d", &v1, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", T + i);
    if (T[i] == 1) {
      scanf("%d %d", p + i, v + i);
      p[i]--;
      G[p[i]].push_back(n++);
    } else {
      scanf("%d", v + i);
      v[i]--;
    }
  }
  for (int i = 0; i < n; i++) s[i] = 1;
  dfs(0);
  build_tree(0, n - 1);
  inv[1] = 1;
  for (int i = 2; i < n; i++) inv[i] = md - ((md / i) * 1ll * inv[md % i]) % md;
  add(1, pos[0], v1);
  for (int i = 0, k = 1; i < q; i++)
    if (T[i] == 1) {
      mult(1, pos[p[i]], last[p[i]], (inv[s[p[i]]] * 1ll * (s[p[i]] + 1)) % md);
      s[p[i]]++;
      add(1, pos[k++], v[i]);
    } else {
      int ans = query(1, pos[v[i]], last[v[i]]);
      ans = (ans * ololo(prod(1, pos[v[i]]), md - 2)) % md;
      ans = (s[v[i]] * 1ll * ans) % md;
      printf("%d\n", ans);
    }
  return 0;
}