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 maxn = 200100;
int n, q, tot;
int v[maxn], ty[maxn], p[maxn], dfn[maxn], ed[maxn], fa[maxn], d[maxn],
    re[maxn];
int val[maxn * 4], tag[maxn * 4];
vector<int> g[maxn];
inline void mul(int &a, int b) { a = (long long)a * b % 1000000007; }
int pow(int a, int b) {
  int ans = 1;
  for (; b; mul(a, a), b >>= 1)
    if (b & 1) mul(ans, a);
  return ans;
}
void dfs(int t) {
  re[dfn[t] = ++tot] = t;
  for (auto v : g[t]) dfs(v);
  ed[t] = tot;
}
void update(int t) {
  val[t] = (val[(t << 1)] + val[((t << 1) | 1)]) % 1000000007;
}
void build(int t, int l, int r) {
  tag[t] = 1;
  if (l == r) {
    if (l == 1) val[t] = v[1];
    return;
  }
  build((t << 1), l, ((l + r) >> 1));
  build(((t << 1) | 1), ((l + r) >> 1) + 1, r);
  update(t);
}
void down(int t) {
  if (tag[t] != 1) {
    mul(val[(t << 1)], tag[t]);
    mul(val[((t << 1) | 1)], tag[t]);
    mul(tag[(t << 1)], tag[t]);
    mul(tag[((t << 1) | 1)], tag[t]);
    tag[t] = 1;
  }
}
void modify_seg(int t, int l, int r, int x, int y, int v) {
  if (l != r) down(t);
  if (x <= l && y >= r) {
    mul(tag[t], v);
    mul(val[t], v);
    return;
  }
  if (x <= ((l + r) >> 1)) modify_seg((t << 1), l, ((l + r) >> 1), x, y, v);
  if (y > ((l + r) >> 1))
    modify_seg(((t << 1) | 1), ((l + r) >> 1) + 1, r, x, y, v);
  update(t);
}
void modify_poi(int t, int l, int r, int x) {
  if (l != r)
    down(t);
  else {
    val[t] = (long long)v[re[x]] * tag[t] % 1000000007;
    return;
  }
  if (x <= ((l + r) >> 1))
    modify_poi((t << 1), l, ((l + r) >> 1), x);
  else
    modify_poi(((t << 1) | 1), ((l + r) >> 1) + 1, r, x);
  update(t);
}
int query(int t, int l, int r, int x, int y) {
  if (l != r) down(t);
  if (x <= l && y >= r) return val[t];
  if (y <= ((l + r) >> 1))
    return query((t << 1), l, ((l + r) >> 1), x, y);
  else if (x > ((l + r) >> 1))
    return query(((t << 1) | 1), ((l + r) >> 1) + 1, r, x, y);
  else
    return (query((t << 1), l, ((l + r) >> 1), x, y) +
            query(((t << 1) | 1), ((l + r) >> 1) + 1, r, x, y)) %
           1000000007;
}
int ask(int t, int l, int r, int x) {
  if (!x) return 1;
  if (l != r)
    down(t);
  else
    return tag[t];
  if (x <= ((l + r) >> 1))
    return ask((t << 1), l, ((l + r) >> 1), x);
  else
    return ask(((t << 1) | 1), ((l + r) >> 1) + 1, r, x);
}
int main() {
  cin >> v[n = 1] >> q;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &ty[i], &p[i]);
    if (ty[i] == 1) {
      scanf("%d", &v[++n]);
      fa[n] = p[i];
      g[p[i]].push_back(n);
      p[i] = n;
    }
  }
  dfs(1);
  d[1] = 1;
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    if (ty[i] == 1) {
      modify_seg(1, 1, n, dfn[fa[p[i]]], ed[fa[p[i]]],
                 (long long)(d[fa[p[i]]] + 1) *
                     pow(d[fa[p[i]]], 1000000007 - 2) % 1000000007);
      d[fa[p[i]]]++;
      d[p[i]]++;
      modify_poi(1, 1, n, dfn[p[i]]);
    } else {
      printf("%d\n", int((long long)query(1, 1, n, dfn[p[i]], ed[p[i]]) *
                         pow(ask(1, 1, n, dfn[fa[p[i]]]), 1000000007 - 2) %
                         1000000007));
    }
  }
  return 0;
}