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;
int n, tip[1000005], val[1000005], p[1000005], l, coef[1000005], nrfii[1000005],
    nr[1000005];
int aint[4 * 1000005], sum[4 * 1000005], NOD, fat[1000005], nod[1000005];
vector<int> L[1000005];
inline void Dfs(int nod, int tata) {
  p[nod] = ++l;
  fat[nod] = tata;
  for (auto it : L[nod]) {
    if (it == tata) continue;
    Dfs(it, nod);
    nrfii[nod] += nrfii[it] + 1;
  }
}
inline void Propag(int nod) {
  if (aint[nod] == 1) return;
  aint[2 * nod] = (1LL * aint[2 * nod] * aint[nod]) % 1000000007;
  aint[2 * nod + 1] = (1LL * aint[2 * nod + 1] * aint[nod]) % 1000000007;
  sum[2 * nod] = (1LL * sum[2 * nod] * aint[nod]) % 1000000007;
  sum[2 * nod + 1] = (1LL * sum[2 * nod + 1] * aint[nod]) % 1000000007;
  aint[nod] = 1;
}
inline int Qry(int nod, int st, int dr, int x, int y) {
  if (st == x && y == dr) return sum[nod];
  Propag(nod);
  int mij = ((st + dr) >> 1);
  if (y <= mij)
    return Qry(2 * nod, st, mij, x, y);
  else if (x > mij)
    return Qry(2 * nod + 1, mij + 1, dr, x, y);
  else
    return (Qry(2 * nod, st, mij, x, mij) +
            Qry(2 * nod + 1, mij + 1, dr, mij + 1, y)) %
           1000000007;
}
inline int Pow_Log(int x, int p) {
  int sol = 1;
  while (p) {
    if (p & 1) {
      sol = (1LL * sol * x) % 1000000007;
      --p;
    }
    p >>= 1;
    x = (1LL * x * x) % 1000000007;
  }
  return sol;
}
inline void Upd(int nod, int st, int dr, int x, int y, int val) {
  if (st == x && y == dr) {
    aint[nod] = (1LL * aint[nod] * val) % 1000000007;
    sum[nod] = (1LL * sum[nod] * val) % 1000000007;
    NOD = nod;
    return;
  }
  Propag(nod);
  int mij = ((st + dr) >> 1);
  if (y <= mij)
    Upd(2 * nod, st, mij, x, y, val);
  else if (x > mij)
    Upd(2 * nod + 1, mij + 1, dr, x, y, val);
  else {
    Upd(2 * nod, st, mij, x, mij, val);
    Upd(2 * nod + 1, mij + 1, dr, mij + 1, y, val);
  }
  sum[nod] = (sum[2 * nod] + sum[2 * nod + 1]) % 1000000007;
}
inline int Coef(int nod) {
  if (!nod) return 1;
  Upd(1, 1, n, p[nod], p[nod], 1);
  return (1LL * coef[nod] * aint[NOD]) % 1000000007;
}
inline void Add(int nod, int st, int dr, int x, int val) {
  if (st == dr) {
    sum[nod] = val;
    return;
  }
  Propag(nod);
  int mij = ((st + dr) >> 1);
  if (x <= mij)
    Add(2 * nod, st, mij, x, val);
  else
    Add(2 * nod + 1, mij + 1, dr, x, val);
  sum[nod] = (sum[2 * nod] + sum[2 * nod + 1]) % 1000000007;
}
int main() {
  int i, j, cnt = 1, q;
  cin.sync_with_stdio(0);
  cin >> val[1] >> q;
  for (i = 1; i <= q; ++i) {
    cin >> tip[i];
    if (tip[i] == 2)
      cin >> nod[i];
    else {
      ++cnt;
      cin >> nod[i] >> val[cnt];
      L[cnt].push_back(nod[i]);
      L[nod[i]].push_back(cnt);
    }
  }
  n = cnt;
  for (i = 1; i <= 4 * n; ++i) aint[i] = 1;
  Dfs(1, 0);
  coef[1] = 1;
  Add(1, 1, n, 1, val[1]);
  for (i = cnt = 1; i <= q; ++i)
    if (tip[i] == 1) {
      ++cnt;
      int kkt =
          (1LL * (nr[nod[i]] + 2) * Pow_Log(nr[nod[i]] + 1, 1000000007 - 2)) %
          1000000007;
      Upd(1, 1, n, p[nod[i]], p[nod[i]] + nrfii[nod[i]], kkt);
      Upd(1, 1, n, p[cnt], p[cnt], 1);
      aint[NOD] = 1;
      coef[cnt] = Coef(nod[i]);
      Add(1, 1, n, p[cnt], (1LL * val[cnt] * coef[cnt]) % 1000000007);
      ++nr[nod[i]];
    } else {
      int val = Qry(1, 1, n, p[nod[i]], p[nod[i]] + nrfii[nod[i]]);
      val =
          (1LL * val * Pow_Log(Coef(fat[nod[i]]), 1000000007 - 2)) % 1000000007;
      cout << val << "\n";
    }
  return 0;
}