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;
template <class T, class L>
bool smax(T& x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T& x, L y) {
  return x > y ? (x = y, 1) : 0;
}
const int maxn = 2e5 + 17, mod = 1e9 + 7;
struct Seg {
  int lazy[maxn << 2], s[maxn << 2];
  void build(int l = 0, int r = maxn, int id = 1) {
    s[id] = r - l;
    if (r - l < 2) return;
    int mid = l + r >> 1;
    build(l, mid, id << 1), build(mid, r, id << 1 | 1);
  }
  Seg() { fill(lazy, lazy + (maxn << 2), 1), build(); }
  void shift(int id) {
    lazy[id << 1] = (long long)lazy[id << 1] * lazy[id] % mod,
               lazy[id << 1 | 1] =
                   (long long)lazy[id << 1 | 1] * lazy[id] % mod;
    s[id << 1] = (long long)s[id << 1] * lazy[id] % mod,
            s[id << 1 | 1] = (long long)s[id << 1 | 1] * lazy[id] % mod;
    lazy[id] = 1;
  }
  void add(int st, int en, int v, int l = 0, int r = maxn, int id = 1) {
    if (st <= l && r <= en) {
      s[id] = (long long)s[id] * v % mod,
      lazy[id] = (long long)lazy[id] * v % mod;
      return;
    }
    if (en <= l || r <= st) return;
    shift(id);
    int mid = l + r >> 1;
    add(st, en, v, l, mid, id << 1), add(st, en, v, mid, r, id << 1 | 1);
    s[id] = (s[id << 1] + s[id << 1 | 1]) % mod;
  }
  int get(int st, int en, int l = 0, int r = maxn, int id = 1) {
    if (st <= l && r <= en) return s[id];
    if (en <= l || r <= st) return 0;
    shift(id);
    int mid = l + r >> 1;
    return (get(st, en, l, mid, id << 1) + get(st, en, mid, r, id << 1 | 1)) %
           mod;
  }
  void add(int l, int v) { add(l, l + 1, v); }
  int get(int l) { return get(l, l + 1); }
} d, po, bad;
struct Q {
  int t, p, v;
} q[maxn];
int rev(int a) {
  int b = mod - 2, ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
  }
  return ans;
}
int tim, st[maxn], en[maxn], nq, deg[maxn], cnt = 1;
vector<int> g[maxn];
void dfs(int v = 0) {
  st[v] = tim++;
  for (auto u : g[v]) dfs(u);
  en[v] = tim;
}
void DeemoLovesInit() {
  int tmp;
  cin >> tmp >> nq;
  po.add(0, tmp);
  bad.add(0, 0);
  fill(deg, deg + maxn, 1);
  for (int i = 0; i < nq && cin >> q[i].t; i++)
    if (q[i].t == 1)
      cin >> q[i].p >> q[i].v, g[--q[i].p].push_back(cnt++);
    else
      cin >> q[i].v, q[i].v--;
  dfs();
  cnt = 1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie();
  DeemoLovesInit();
  for (int i = 0, t = q[i].t, v = q[i].v, p = q[i].p; i < nq;
       i++, t = q[i].t, v = q[i].v, p = q[i].p)
    if (t == 1) {
      po.add(st[cnt],
             (long long)rev(po.get(st[cnt])) * v % mod * d.get(st[p]) % mod);
      bad.add(st[cnt], 0);
      deg[p]++;
      d.add(st[p], en[p], (long long)rev(deg[p] - 1) * deg[p] % mod);
      po.add(st[p], en[p], (long long)rev(deg[p] - 1) * deg[p] % mod);
      bad.add(st[p], en[p], (long long)rev(deg[p] - 1) * deg[p] % mod);
      cnt++;
    } else {
      cout << (long long)(po.get(st[v], en[v]) - bad.get(st[v], en[v]) + mod) %
                  mod * rev(d.get(st[v])) % mod * deg[v] % mod
           << '\n';
    }
  return 0;
}