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 P = 1e9 + 7;
vector<int> b[200005];
int L[200005], R[200005], u[200005], v[200005], opt[200005], size[200005];
int m, n, ql, qr, upd, tot, now, ans, i, x;
struct data {
  int cnt, sum;
  data() { cnt = 1; }
  void multi(int x) {
    cnt = 1ll * cnt * x % P;
    sum = 1ll * sum * x % P;
  }
  int renew(int x) {
    cnt = 1;
    sum = x;
    return 0;
  }
} a[200005 << 2];
void DFS(int x, int Fa) {
  L[x] = ++tot;
  for (int i = 0, y; i < b[x].size(); i++)
    if ((y = b[x][i]) != Fa) DFS(y, x);
  R[x] = tot;
}
int INV(int a) {
  int ret = 1, b = P - 2;
  for (; b; b >>= 1, a = 1ll * a * a % P)
    if (b & 1) ret = 1ll * ret * a % P;
  return ret;
}
inline void down(int x) {
  if (a[x].cnt == 1) return;
  a[x << 1].multi(a[x].cnt);
  a[x << 1 | 1].multi(a[x].cnt);
  a[x].cnt = 1;
}
inline void up(int x) { a[x].sum = (a[x << 1].sum + a[x << 1 | 1].sum) % P; }
void Multi(int x, int l, int r) {
  if (ql <= l && r <= qr) {
    a[x].multi(now);
    return;
  }
  int mid = (l + r) >> 1;
  down(x);
  if (ql <= mid) Multi(x << 1, l, mid);
  if (qr > mid) Multi(x << 1 | 1, mid + 1, r);
  up(x);
}
int Update(int x, int l, int r, int pos) {
  if (l == r) return (!upd) ? a[x].sum : a[x].renew(now);
  int mid = (l + r) >> 1;
  down(x);
  int ret = (pos <= mid) ? Update(x << 1, l, mid, pos)
                         : Update(x << 1 | 1, mid + 1, r, pos);
  return up(x), ret;
}
void Query(int x, int l, int r) {
  if (ql <= l && r <= qr) {
    ans = (ans + a[x].sum) % P;
    return;
  }
  int mid = (l + r) >> 1;
  down(x);
  if (ql <= mid) Query(x << 1, l, mid);
  if (qr > mid) Query(x << 1 | 1, mid + 1, r);
}
int main() {
  scanf("%d%d", &v[1], &m);
  n = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &opt[i], &u[i]);
    if (opt[i] == 1) scanf("%d", &v[++n]), b[u[i]].push_back(n);
  }
  DFS(1, 0);
  size[n = 1] = 1;
  upd = 1;
  now = v[1];
  Update(1, 1, tot, L[1]);
  for (i = 1; i <= m; i++)
    if (opt[i] == 1) {
      x = u[i];
      size[++n] = 1;
      ql = L[x];
      qr = R[x];
      now = 1ll * (size[x] + 1) * INV(size[x]) % P;
      ++size[x];
      Multi(1, 1, tot);
      upd = 0;
      now = Update(1, 1, tot, L[x]);
      now = 1ll * now * INV(v[x]) % P;
      now = 1ll * now * v[n] % P;
      upd = 1;
      Update(1, 1, tot, L[n]);
    } else {
      x = u[i];
      ans = 0;
      ql = L[x];
      qr = R[x];
      Query(1, 1, tot);
      upd = 0;
      now = Update(1, 1, tot, L[x]);
      now = 1ll * now * INV(1ll * v[x] * size[x] % P) % P;
      ans = 1ll * ans * INV(now) % P;
      printf("%d\n", ans);
    }
}