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 mod = 1e9 + 7;
const int N = 2e5 + 10;
struct Q {
  int q, u, val;
  void input() {
    scanf("%d", &q);
    if (q == 1)
      scanf("%d %d", &u, &val);
    else
      scanf("%d", &u);
  }
} q[N];
vector<int> g[N];
int s[N << 2], tag[N << 2], c[N], tot, st[N], en[N];
int d[N], p[N];
int power(int x, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod;
    n >>= 1;
  }
  return res;
}
int Inv(int x) {
  int res = power(x, mod - 2);
  return res;
}
int mul(int x, int y) { return 1ll * x * y % mod; }
void down(int k) {
  if (tag[k] > 1) {
    s[k << 1] = mul(s[k << 1], tag[k]);
    s[k << 1 | 1] = mul(s[k << 1 | 1], tag[k]);
    tag[k << 1] = mul(tag[k << 1], tag[k]);
    tag[k << 1 | 1] = mul(tag[k << 1 | 1], tag[k]);
    tag[k] = 1;
  }
}
void build(int l, int r, int k) {
  s[k] = 0;
  tag[k] = 1;
  if (l == r) return;
  int m = l + r >> 1;
  build(l, m, k << 1);
  build(m + 1, r, k << 1 | 1);
  s[k] = (s[k << 1] + s[k << 1 | 1]) % mod;
}
void update(int val, int la, int ra, int l, int r, int k) {
  if (la <= l && ra >= r) {
    tag[k] = mul(tag[k], val);
    s[k] = mul(s[k], val);
    return;
  }
  int m = l + r >> 1;
  down(k);
  if (la <= m) {
    update(val, la, ra, l, m, k << 1);
  }
  if (ra > m) {
    update(val, la, ra, m + 1, r, k << 1 | 1);
  }
  s[k] = (s[k << 1] + s[k << 1 | 1]) % mod;
}
void update2(int pos, int l, int r, int k) {
  if (pos == l && l == r) {
    s[k] = 1;
    s[k] = mul(s[k], tag[k]);
    return;
  }
  int m = l + r >> 1;
  down(k);
  if (pos <= m) {
    update2(pos, l, m, k << 1);
  } else if (pos > m) {
    update2(pos, m + 1, r, k << 1 | 1);
  }
  s[k] = (s[k << 1] + s[k << 1 | 1]) % mod;
}
int query(int la, int ra, int l, int r, int k) {
  if (la <= l && ra >= r) {
    return s[k];
  }
  int m = l + r >> 1;
  down(k);
  int res = 0;
  if (la <= m) res = query(la, ra, l, m, k << 1);
  if (ra > m) res = (res + query(la, ra, m + 1, r, k << 1 | 1)) % mod;
  s[k] = (s[k << 1] + s[k << 1 | 1]) % mod;
  return res;
}
int dfs_clock;
void dfs(int u, int f) {
  st[u] = ++dfs_clock;
  for (auto &v : g[u]) {
    if (v == f) continue;
    dfs(v, u);
  }
  en[u] = dfs_clock;
}
int n;
void solve() {
  tot = 1;
  scanf("%d %d", &c[1], &n);
  for (int i = 1; i <= n; i++) {
    q[i].input();
  }
  for (int i = 1; i <= n; i++) {
    if (q[i].q == 1) {
      tot++;
      p[i] = tot;
      c[tot] = q[i].val;
      g[q[i].u].push_back(tot);
    }
  }
  build(1, tot, 1);
  dfs(1, -1);
  for (int i = 1; i <= tot; i++) {
    update(c[i], st[i], st[i], 1, tot, 1);
  }
  update2(1, 1, tot, 1);
  int now = 1;
  for (int i = 1; i <= n; i++) {
    if (q[i].q == 1) {
      now++;
      int u = q[i].u;
      int del = 1ll * (d[u] + 2) * Inv(d[u] + 1) % mod;
      update(del, st[u], en[u], 1, tot, 1);
      update2(st[p[i]], 1, tot, 1);
      d[u]++;
    } else {
      int u = q[i].u;
      int seg = query(st[u], en[u], 1, tot, 1);
      int val = query(st[u], st[u], 1, tot, 1);
      int num = 1ll * val * Inv(d[u] + 1) % mod * Inv(c[u]) % mod;
      int ans = 1ll * seg * Inv(num) % mod;
      printf("%d\n", ans);
    }
  }
}
int main() { solve(); }