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>
const long long mod = 1000000007;
using namespace std;
int len, nex[500000], hea[500000], wen[500000], l[500000], r[500000], q, n, cnt,
    fa[500000];
long long lazy[2000000], c[2000000], b[500000], v[500000], ans, inv;
struct arr {
  int bo, x;
} a[500000];
void add(int x, int y) {
  ++len;
  nex[len] = hea[x];
  wen[len] = y;
  hea[x] = len;
}
void dfs(int x) {
  l[x] = ++cnt;
  for (int i = hea[x]; i; i = nex[i]) dfs(wen[i]);
  r[x] = cnt;
}
void pushdown(int k) {
  if (lazy[k] == 1) return;
  long long t = lazy[k];
  c[k * 2] = c[k * 2] * t % mod;
  c[k * 2 + 1] = c[k * 2 + 1] * t % mod;
  lazy[k * 2] = lazy[k * 2] * t % mod;
  lazy[k * 2 + 1] = lazy[k * 2 + 1] * t % mod;
  lazy[k] = 1;
}
void update1(int l, int r, int k, int x, long long s) {
  if (l == r) {
    c[k] = s * lazy[k] % mod;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(k);
  if (x <= mid)
    update1(l, mid, k * 2, x, s);
  else
    update1(mid + 1, r, k * 2 + 1, x, s);
  c[k] = (c[k * 2] + c[k * 2 + 1]) % mod;
}
void update2(int l, int r, int k, int x, int y, long long z) {
  if (l >= x && y >= r) {
    lazy[k] = lazy[k] * z % mod;
    c[k] = c[k] * z % mod;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(k);
  if (x <= mid) update2(l, mid, k * 2, x, y, z);
  if (y > mid) update2(mid + 1, r, k * 2 + 1, x, y, z);
  c[k] = (c[k * 2] + c[k * 2 + 1]) % mod;
}
long long find(int l, int r, int k, int x, int y) {
  if (l >= x && y >= r) return (c[k] % mod);
  int mid = (l + r) >> 1;
  long long sum = 0;
  pushdown(k);
  if (x <= mid) sum += find(l, mid, k * 2, x, y);
  if (y > mid) sum += find(mid + 1, r, k * 2 + 1, x, y);
  return (sum % mod);
}
long long kp(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return (a % mod);
  long long c = kp(a, b / 2);
  c = (c * c) % mod;
  if (b & 1) c = (c * a) % mod;
  return c;
}
int main() {
  scanf("%lld%d", &v[1], &q);
  n = b[1] = 1;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &a[i].bo, &a[i].x);
    if (2 - a[i].bo) {
      ++n;
      scanf("%lld", &v[n]);
      add(a[i].x, n);
      fa[n] = a[i].x;
    }
  }
  dfs(1);
  for (int i = 1; i <= n * 4; i++) lazy[i] = 1;
  update1(1, n, 1, 1, v[1]);
  int k = 1;
  for (int i = 1; i <= q; i++) {
    if (2 - a[i].bo) {
      ++k;
      ++b[a[i].x];
      ++b[k];
      update1(1, n, 1, l[k], v[k]);
      update2(1, n, 1, l[a[i].x], r[a[i].x],
              b[a[i].x] * kp(b[a[i].x] - 1, mod - 2) % mod);
    } else {
      int u = a[i].x;
      ans = find(1, n, 1, l[u], r[u]);
      if (u != 1)
        inv = v[fa[u]] * kp(find(1, n, 1, l[fa[u]], l[fa[u]]), mod - 2) % mod;
      else
        inv = 1;
      ans = ans * inv % mod;
      printf("%lld\n", ans);
    }
  }
}