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 N = 200005;
const int mod = 1e9 + 7;
int n, sz[N], son[N], top[N], id[N], ty[N], f[N], o[N], val[N], tot;
vector<int> g[N];
void dfs_1(int u, int fa) {
  sz[u]++;
  f[u] = fa;
  pair<int, int> mx = make_pair(0, 0);
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    if (v != fa) {
      dfs_1(v, u);
      sz[u] += sz[v];
      mx = max(mx, make_pair(sz[v], v));
    }
  }
  son[u] = mx.second;
}
void dfs_2(int u, int fa) {
  id[u] = ++tot;
  if (son[u]) {
    top[son[u]] = top[u];
    dfs_2(son[u], u);
  }
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    if (v != son[u] && v != fa) {
      top[v] = v;
      dfs_2(v, u);
    }
  }
}
struct node {
  int sum, mul;
  bool lazy;
} t[N << 2];
void push_down(int u) {
  if (t[u].lazy) {
    t[u << 1].sum =
        (t[u << 1].sum + 1LL * t[u].sum * t[u << 1 | 1].mul % mod) % mod;
    t[u << 1 | 1].sum = (t[u << 1 | 1].sum + t[u].sum) % mod;
    t[u << 1].lazy = t[u << 1 | 1].lazy = 1;
    t[u].sum = 0;
    t[u].lazy = 0;
  }
}
int update_sum(int u, int l, int r, int L, int R, int v) {
  if (l == L && r == R) {
    t[u].sum = (t[u].sum + v) % mod;
    t[u].lazy = 1;
    return t[u].mul;
  }
  push_down(u);
  int mid = (l + r) / 2;
  if (R <= mid)
    return update_sum(u << 1, l, mid, L, R, v);
  else if (L > mid)
    return update_sum(u << 1 | 1, mid + 1, r, L, R, v);
  else {
    int res = update_sum(u << 1 | 1, mid + 1, r, mid + 1, R, v);
    res = 1LL * res * update_sum(u << 1, l, mid, L, mid, 1LL * v * res % mod) %
          mod;
    return res;
  }
}
void update_mul(int u, int l, int r, int x) {
  if (l == r) {
    t[u].mul++;
    return;
  }
  push_down(u);
  int mid = (l + r) / 2;
  if (x <= mid)
    update_mul(u << 1, l, mid, x);
  else
    update_mul(u << 1 | 1, mid + 1, r, x);
  t[u].mul = 1LL * t[u << 1].mul * t[u << 1 | 1].mul % mod;
}
pair<int, int> query(int u, int l, int r, int x) {
  if (l == r) return make_pair(t[u].mul, t[u].sum);
  push_down(u);
  int mid = (l + r) / 2;
  if (x <= mid)
    return query(u << 1, l, mid, x);
  else
    return query(u << 1 | 1, mid + 1, r, x);
}
int main() {
  int V, q;
  scanf("%d%d", &V, &q);
  int cnt = 1;
  for (int i = 1; i <= q; i++) {
    scanf("%d", &ty[i]);
    if (ty[i] == 1) {
      scanf("%d%d", &o[i], &val[i]);
      cnt++;
      g[o[i]].push_back(cnt);
      g[cnt].push_back(o[i]);
    } else
      scanf("%d", &o[i]);
  }
  top[1] = 1;
  dfs_1(1, 0);
  dfs_2(1, 0);
  update_sum(1, 1, tot, id[1], id[1], V);
  update_mul(1, 1, tot, id[1]);
  cnt = 1;
  for (int i = 1; i <= q; i++) {
    if (ty[i] == 1) {
      cnt++;
      update_sum(1, 1, tot, id[cnt], id[cnt], val[i]);
      update_mul(1, 1, tot, id[cnt]);
      pair<int, int> res = query(1, 1, tot, id[o[i]]);
      int ad = (res.second + 1LL * (res.first + 1) * val[i] % mod) % mod;
      update_sum(1, 1, tot, id[o[i]], id[o[i]], val[i]);
      update_mul(1, 1, tot, id[o[i]]);
      int x = f[o[i]];
      while (x) {
        int y = top[x];
        int res = update_sum(1, 1, tot, id[y], id[x], ad);
        ad = 1LL * res * ad % mod;
        x = f[y];
      }
    } else {
      pair<int, int> res = query(1, 1, tot, id[o[i]]);
      printf("%d\n", 1LL * res.first * res.second % mod);
    }
  }
  return 0;
}