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 long long p = 1000000007;
int q[200005][3];
int n, cnt = 1;
vector<int> c[200005];
int v[200005];
int l[200005];
int r[200005];
int f[200005];
long long rev[200005];
void eec_solve(long long& a, const long long x, long long& b,
               const long long y) {
  if (y == 0) {
    a = 1;
    b = 0;
    return;
  }
  long long q = x / y, r = x % y, c = 0, d = 0;
  eec_solve(c, y, d, r);
  a = d;
  b = c - a * q;
}
int solve_lr(int ind, int cur) {
  l[ind] = cur;
  int tmp = 1;
  for (int i = 0; i < c[ind].size(); ++i) tmp += solve_lr(c[ind][i], cur + tmp);
  r[ind] = cur + tmp - 1;
  return tmp;
}
struct seg {
  long long v, c;
};
seg segt[800005];
void init(int x, int ll, int rr) {
  segt[x].v = 0;
  segt[x].c = 1;
  if (ll != rr) {
    segt[x].v = 0;
    segt[x].c = 1;
    int k = (ll + rr) >> 1;
    init(x << 1, ll, k);
    init((x << 1) | 1, k + 1, rr);
  }
}
void insert(int ind, int v) {
  int x = 1, ll = 1, rr = cnt, k;
  long long cum = v;
  while (ll != rr) {
    k = (ll + rr) >> 1;
    if (ind <= k) {
      x = x << 1;
      rr = k;
    } else {
      x = (x << 1) | 1;
      ll = k + 1;
    }
  }
  while (x > 0) {
    segt[x].v = (segt[x].v + cum) % p;
    cum = (cum * segt[x].c) % p;
    x = x >> 1;
  }
}
void change(int x, int ll, int rr, int i, int j, int cc) {
  if ((ll == i) && (rr == j)) {
    segt[x].c = (((segt[x].c * rev[cc]) % p) * (cc + 1)) % p;
    return;
  }
  int k = (ll + rr) >> 1;
  if (i <= k) change(x << 1, ll, k, i, min(k, j), cc);
  if (j > k) change((x << 1) | 1, k + 1, rr, max(i, k + 1), j, cc);
  segt[x].v = (segt[x << 1].v * segt[x << 1].c +
               segt[(x << 1) | 1].v * segt[(x << 1) | 1].c) %
              p;
}
long long sum(int x, int ll, int rr, int i, int j) {
  if ((ll == i) && (rr == j)) return (segt[x].v * segt[x].c) % p;
  int k = (ll + rr) >> 1;
  long long res = 0;
  if (i <= k) res += sum(x << 1, ll, k, i, min(k, j));
  if (j > k) res += sum((x << 1) | 1, k + 1, rr, max(i, k + 1), j);
  return ((res % p) * segt[x].c) % p;
}
long long getC(int ind) {
  long long res = 1;
  int x = 1, ll = 1, rr = cnt, k;
  while (ll != rr) {
    res = (res * segt[x].c) % p;
    k = (ll + rr) >> 1;
    if (ind <= k) {
      x = x << 1;
      rr = k;
    } else {
      x = (x << 1) | 1;
      ll = k + 1;
    }
  }
  res = (res * segt[x].c) % p;
  return res;
}
int main() {
  scanf("%d %d", &v[1], &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &q[i][0], &q[i][1]);
    if (q[i][0] == 1) {
      scanf("%d", &q[i][2]);
      v[++cnt] = q[i][2];
      c[q[i][1]].push_back(cnt);
      f[cnt] = q[i][1];
      q[i][2] = c[q[i][1]].size();
    }
  }
  for (int i = 1; i <= cnt; ++i) {
    eec_solve(rev[i], i, rev[i + 1], p);
    rev[i] = ((rev[i] % p) + p) % p;
  }
  solve_lr(1, 1);
  init(1, 1, cnt);
  insert(1, v[1]);
  int new_cnt = 1;
  for (int i = 0; i < n; ++i)
    if (q[i][0] == 1) {
      ++new_cnt;
      insert(l[new_cnt], v[new_cnt]);
      change(1, 1, cnt, l[q[i][1]], r[q[i][1]], q[i][2]);
    } else {
      long long res = sum(1, 1, cnt, l[q[i][1]], r[q[i][1]]);
      if (q[i][1] != 1) {
        long long x = getC(l[f[q[i][1]]]);
        long long ta, tb;
        eec_solve(ta, x, tb, p);
        ta = ((ta % p) + p) % p;
        res = (res * ta) % p;
      }
      cout << res << endl;
    }
  return 0;
}