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 = (int)2e5 + 3;
const int infint = (int)1e9 + 9;
const int MOD = (int)1e9 + 7;
const long long inf = (long long)1e18 + 3;
int add(int x, int y) {
  int c = x + y;
  if (c >= MOD) c -= MOD;
  if (c < 0) c += MOD;
  return c;
}
int mul(int x, int y) {
  int c = 1LL * x * y % MOD;
  return c;
}
int pwr(int a, int b) {
  if (!b) return 1;
  int c = pwr(a, b >> 1);
  c = mul(c, c);
  if (b & 1) c = mul(c, a);
  return c;
}
int inv(int p) { return pwr(p, MOD - 2); }
int v[MAXN], n;
int tp[MAXN], fir[MAXN], sec[MAXN], v1, q, st[MAXN], en[MAXN], par[MAXN],
    tme = 0;
vector<int> G[MAXN];
void dfs(int u) {
  st[u] = tme;
  for (auto v : G[u]) par[v] = u, tme++, dfs(v);
  en[u] = tme;
}
struct segment {
  int value[4 * MAXN], f[4 * MAXN], lazyf[4 * MAXN];
  void merge(int node) {
    f[node] = add(f[node << 1], f[node << 1 | 1]);
    value[node] = add(value[node << 1], value[node << 1 | 1]);
    return;
  }
  void build(int node, int st, int en) {
    lazyf[node] = 1;
    if (en - st < 2) {
      f[node] = 1;
      return;
    }
    int mid = (st + en) >> 1;
    build(node << 1, st, mid);
    build(node << 1 | 1, mid, en);
    merge(node);
  }
  void updf(int node, int st, int en, int x) {
    f[node] = mul(f[node], x);
    lazyf[node] = mul(lazyf[node], x);
    value[node] = mul(value[node], x);
    return;
  }
  void shiftf(int node, int st, int en) {
    int mid = (st + en) >> 1;
    updf(node << 1, st, mid, lazyf[node]);
    updf(node << 1 | 1, mid, en, lazyf[node]);
    lazyf[node] = 1;
    return;
  }
  void updatef(int node, int st, int en, int l, int r, int x) {
    if (l >= en || st >= r) return;
    if (l <= st && en <= r) {
      updf(node, st, en, x);
      return;
    }
    int mid = (st + en) >> 1;
    shiftf(node, st, en);
    updatef(node << 1, st, mid, l, r, x);
    updatef(node << 1 | 1, mid, en, l, r, x);
    merge(node);
    return;
  }
  int askf(int node, int st, int en, int idx) {
    if (en - st < 2) return f[node];
    int mid = (st + en) >> 1;
    shiftf(node, st, en);
    if (idx < mid)
      return askf(node << 1, st, mid, idx);
    else
      return askf(node << 1 | 1, mid, en, idx);
  }
  void update(int node, int st, int en, int idx, int val) {
    if (en - st < 2) {
      value[node] = add(value[node], mul(val, f[node]));
      return;
    }
    int mid = (st + en) >> 1;
    shiftf(node, st, en);
    if (idx < mid)
      update(node << 1, st, mid, idx, val);
    else
      update(node << 1 | 1, mid, en, idx, val);
    merge(node);
    return;
  }
  int get(int node, int st, int en, int l, int r) {
    if (l >= en || st >= r) return 0;
    if (l <= st && en <= r) return value[node];
    int mid = (st + en) >> 1;
    shiftf(node, st, en);
    return add(get(node << 1, st, mid, l, r),
               get(node << 1 | 1, mid, en, l, r));
  }
} her;
int curf[MAXN];
void add_vertex(int ver, int val) {
  int p = par[ver];
  if (p) {
    her.updatef(1, 0, n, st[p], en[p] + 1, inv(curf[p]));
    her.updatef(1, 0, n, st[p], en[p] + 1, ++curf[p]);
  }
  her.update(1, 0, n, st[ver], val);
  return;
}
int ask(int ver) {
  int x = her.get(1, 0, n, st[ver], en[ver] + 1);
  int p = par[ver];
  if (p) x = mul(x, inv(her.askf(1, 0, n, st[p])));
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> v1 >> q;
  int idx = 2;
  for (int i = 0; i < q; i++) {
    cin >> tp[i];
    if (tp[i] == 2)
      cin >> fir[i];
    else {
      cin >> fir[i] >> sec[i];
      G[fir[i]].push_back(idx++);
    }
  }
  dfs(1);
  n = idx - 1;
  for (int i = 1; i <= n; i++) curf[i] = 1;
  her.build(1, 0, n);
  add_vertex(1, v1);
  idx = 2;
  for (int i = 0; i < q; i++) {
    if (tp[i] == 2)
      cout << ask(fir[i]) << "\n";
    else
      add_vertex(idx++, sec[i]);
  }
}