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 = 2e5 + 10;
const long long MO = 1e9 + 7;
const long long IN = 1e9;
struct Node {
  int val1, val2, lzy;
} seg[maxn * 4];
struct Query {
  int type, p, v, u;
} qry[maxn];
vector<int> g[maxn];
int sti[maxn], fti[maxn], deg[maxn];
int q, number = 0;
int pw(int a, int b) {
  if (b == 0) return 1;
  int f = pw(a, b / 2);
  return 1LL * f * f % MO * ((b % 2) ? a : 1) % MO;
}
int inv(int x) { return pw(x, MO - 2); }
int dfs0(int v, int parent = -1) {
  sti[v] = fti[v] = number;
  for (auto u : g[v])
    if (u - parent) {
      number++;
      fti[v] = dfs0(u, v);
    }
  return fti[v];
}
void push(int id) {
  if (seg[id].lzy == 1) return;
  seg[id * 2].val1 = 1LL * seg[id * 2].val1 * seg[id].lzy % MO;
  seg[id * 2 + 1].val1 = 1LL * seg[id * 2 + 1].val1 * seg[id].lzy % MO;
  seg[id * 2].val2 = 1LL * seg[id * 2].val2 * seg[id].lzy % MO;
  seg[id * 2 + 1].val2 = 1LL * seg[id * 2 + 1].val2 * seg[id].lzy % MO;
  seg[id * 2].lzy = 1LL * seg[id * 2].lzy * seg[id].lzy % MO;
  seg[id * 2 + 1].lzy = 1LL * seg[id * 2 + 1].lzy * seg[id].lzy % MO;
  seg[id].lzy = 1;
}
void pull(int id) {
  seg[id].val1 = (1LL * seg[id * 2].val1 + seg[id * 2 + 1].val1) % MO;
  seg[id].val2 = (1LL * seg[id * 2].val2 + seg[id * 2 + 1].val2) % MO;
}
void modify(int idx, int val1, int val2, int l = 0, int r = maxn, int id = 1) {
  if (idx >= r || idx < l) return;
  if (r - l == 1) {
    seg[id].val1 = val1;
    seg[id].val2 = val2;
    return;
  }
  int mid = (l + r) >> 1;
  push(id);
  modify(idx, val1, val2, l, mid, id * 2);
  modify(idx, val1, val2, mid, r, id * 2 + 1);
  pull(id);
}
void mul(int st, int en, int val, int l = 0, int r = maxn, int id = 1) {
  if (st >= r || en <= l) return;
  if (st <= l && en >= r) {
    seg[id].val1 = 1LL * seg[id].val1 * val % MO;
    seg[id].val2 = 1LL * seg[id].val2 * val % MO;
    seg[id].lzy = 1LL * seg[id].lzy * val % MO;
    return;
  }
  int mid = (l + r) >> 1;
  push(id);
  mul(st, en, val, l, mid, id * 2);
  mul(st, en, val, mid, r, id * 2 + 1);
  pull(id);
}
pair<int, int> get(int st, int en, int l = 0, int r = maxn, int id = 1) {
  if (st >= r || en <= l) return make_pair(0, 0);
  if (st <= l && en >= r) return make_pair(seg[id].val1, seg[id].val2);
  int mid = (l + r) >> 1;
  push(id);
  pair<int, int> f1 = get(st, en, l, mid, id * 2);
  pair<int, int> f2 = get(st, en, mid, r, id * 2 + 1);
  return make_pair((f1.first + f2.first) % MO, (f1.second + f2.second) % MO);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int v0, num = 1;
  cin >> v0 >> q;
  for (int i = 0; i < q; i++) {
    int type, p, v, u;
    cin >> type;
    if (type == 1) {
      cin >> p >> v;
      --p;
      g[p].push_back(num++);
    }
    if (type == 2) {
      cin >> u;
      --u;
    }
    qry[i].type = type;
    qry[i].p = p;
    qry[i].v = v;
    qry[i].u = u;
  }
  dfs0(0);
  for (int i = 0; i < maxn * 4; i++) seg[i].lzy = 1;
  num = 1;
  deg[0] = 1;
  modify(sti[0], v0, 1);
  for (int i = 0; i < q; i++) {
    if (qry[i].type == 1) {
      int p = qry[i].p, v = qry[i].v, f;
      mul(sti[p], fti[p] + 1, inv(deg[p]++));
      mul(sti[p], fti[p] + 1, deg[p]);
      f = get(sti[p], sti[p] + 1).second;
      deg[num] = 1;
      modify(sti[num++], 1LL * f * v % MO, f);
    }
    if (qry[i].type == 2) {
      int u = qry[i].u;
      int ans = get(sti[u], fti[u] + 1).first;
      ans = 1LL * ans * inv(get(sti[u], sti[u] + 1).second) % MO * deg[u] % MO;
      cout << ans << "\n";
    }
  }
}