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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int cnt, st[200010], ed[200010], a[200010], inv[200010], d[200010], f[200010];
vector<int> g[200010];
pair<int, int> q[200010];
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int Inv(int a) { return pow(a, 1000000007 - 2); }
void dfs(int u) {
  st[u] = ++cnt;
  for (int i = 0; i < g[u].size(); i++) {
    int j = g[u][i];
    dfs(j);
  }
  ed[u] = cnt;
}
int t[200010 << 2], c[200010 << 2], w[200010];
void down(int p) {
  if (c[p] != -1) {
    c[p << 1] = 1LL * c[p << 1] * c[p] % 1000000007;
    t[p << 1] = 1LL * t[p << 1] * c[p] % 1000000007;
    c[p << 1 | 1] = 1LL * c[p << 1 | 1] * c[p] % 1000000007;
    t[p << 1 | 1] = 1LL * t[p << 1 | 1] * c[p] % 1000000007;
    c[p] = 1;
  }
}
void up(int p) { t[p] = (t[p << 1] + t[p << 1 | 1]) % 1000000007; }
void upd(int p, int l, int r, int first, int v) {
  if (l == r) {
    t[p] = 1LL * v * c[p] % 1000000007;
    return;
  }
  int m = (l + r) >> 1;
  down(p);
  if (first <= m)
    upd(p << 1, l, m, first, v);
  else
    upd(p << 1 | 1, m + 1, r, first, v);
  up(p);
}
void mul(int p, int l, int r, int first, int second, int v) {
  if (l >= first && r <= second) {
    c[p] = 1LL * c[p] * v % 1000000007;
    t[p] = 1LL * t[p] * v % 1000000007;
    return;
  }
  int m = (l + r) >> 1;
  down(p);
  if (first <= m) mul(p << 1, l, m, first, second, v);
  if (second > m) mul(p << 1 | 1, m + 1, r, first, second, v);
  up(p);
}
int query(int p, int l, int r, int first, int second) {
  if (l >= first && r <= second) {
    return t[p];
  }
  int m = (l + r) >> 1, a = 0, b = 0;
  down(p);
  if (first <= m) a = query(p << 1, l, m, first, second);
  if (second > m) b = query(p << 1 | 1, m + 1, r, first, second);
  up(p);
  return (a + b) % 1000000007;
}
int ask(int p, int l, int r, int first) {
  if (l == r) {
    return c[p];
  }
  int m = (l + r) >> 1, a = 0, b = 0;
  down(p);
  if (first <= m)
    a = ask(p << 1, l, m, first);
  else
    a = ask(p << 1 | 1, m + 1, r, first);
  up(p);
  return a;
}
void build(int p, int l, int r) {
  c[p] = 1;
  t[p] = 0;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(p << 1, l, m);
  build(p << 1 | 1, m + 1, r);
}
int main() {
  int T, i, j, k, m, n;
  inv[1] = 1;
  for (i = 2; i < 200010; i++) inv[i] = pow(i, 1000000007 - 2);
  n = 1;
  d[1] = 1;
  scanf("%d%d", &a[1], &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &k, &j);
    if (k == 1) {
      scanf("%d", &a[++n]);
      d[n] = 1;
      q[i] = make_pair(1, n);
      g[j].push_back(n);
      f[n] = j;
    } else {
      q[i] = make_pair(2, j);
    }
  }
  dfs(1);
  build(1, 1, n);
  upd(1, 1, n, st[1], a[1]);
  d[0] = 1;
  for (i = 0; i < m; i++) {
    int u = q[i].second;
    if (q[i].first == 1) {
      int v = f[u];
      w[v] = 1;
      upd(1, 1, n, st[u], a[u]);
      mul(1, 1, n, st[v], ed[v], 1LL * inv[d[v]] * (++d[v]) % 1000000007);
    } else {
      if (!w[u])
        printf("%d\n", a[u]);
      else
        printf("%d\n", (long long)query(1, 1, n, st[u], ed[u]) *
                           (f[u] == 0 ? 1 : Inv(ask(1, 1, n, st[f[u]]))) %
                           1000000007);
    }
  }
  return 0;
}