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 long long N = 2e5 + 100;
const long long M = 20;
const long long SQ = 320;
const long long INF = 1e16;
const long long MOD = 1e9 + 7;
int q;
long long a[N];
vector<int> v[N];
pair<long long, long long> qu[N];
int id[N];
int cnt, st[N], ft[N];
int d[N];
long long f[N];
int par[N];
void dfs(int x, int p) {
  par[x] = p;
  st[x] = cnt++;
  for (int i = 0; i < v[x].size(); i++) dfs(v[x][i], x);
  ft[x] = cnt;
}
pair<long long, long long> seg[4 * N];
long long lazy[4 * N];
pair<long long, long long> merge(pair<long long, long long> a,
                                 pair<long long, long long> b) {
  return make_pair((a.first + b.first) % MOD, (a.second + b.second) % MOD);
}
void upd(int v, long long val) {
  seg[v].first = (seg[v].first * val) % MOD;
  seg[v].second = (seg[v].second * val) % MOD;
  lazy[v] = (lazy[v] * val) % MOD;
}
void shift(int v) {
  upd(2 * v, lazy[v]);
  upd(2 * v + 1, lazy[v]);
  lazy[v] = 1;
}
void Set(int v, int l, int r, int x, pair<long long, long long> val) {
  if (x < l || x >= r) return;
  if (r - l < 2) {
    seg[v] = val;
    return;
  }
  shift(v);
  int mid = (l + r) / 2;
  Set(2 * v, l, mid, x, val);
  Set(2 * v + 1, mid, r, x, val);
  seg[v] = merge(seg[2 * v], seg[2 * v + 1]);
}
void mul(int v, int l, int r, int s, int e, long long val) {
  if (e <= l || s >= r) return;
  if (s <= l && e >= r) {
    upd(v, val);
    return;
  }
  shift(v);
  int mid = (l + r) / 2;
  mul(2 * v, l, mid, s, e, val);
  mul(2 * v + 1, mid, r, s, e, val);
  seg[v] = merge(seg[2 * v], seg[2 * v + 1]);
}
pair<long long, long long> sum(int v, int l, int r, int s, int e) {
  if (e <= l || s >= r) return make_pair(0, 0);
  if (s <= l && e >= r) return seg[v];
  shift(v);
  int mid = (l + r) / 2;
  return merge(sum(2 * v, l, mid, s, e), sum(2 * v + 1, mid, r, s, e));
}
long long POW(long long a, long long b) {
  if (b == 1) return a;
  long long ans = POW(a, b / 2);
  ans = ans * ans % MOD;
  if (b % 2)
    return ans * a % MOD;
  else
    return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> a[0] >> q;
  int n = 1;
  for (int i = 0; i < q; i++) {
    cin >> qu[i].first >> qu[i].second;
    qu[i].second--;
    if (qu[i].first == 1) {
      int x;
      cin >> x;
      v[qu[i].second].push_back(n);
      id[i] = n;
      a[n++] = x;
    }
  }
  dfs(0, -1);
  fill(lazy, lazy + 4 * n, 1);
  Set(1, 0, n, 0, make_pair(1, 1 * a[0]));
  for (int i = 0; i < q; i++) {
    int u = qu[i].second;
    if (qu[i].first == 1) {
      mul(1, 0, n, st[u], ft[u], POW(d[u] + 1, MOD - 2));
      d[u]++;
      mul(1, 0, n, st[u], ft[u], d[u] + 1);
      long long t = sum(1, 0, n, st[u], st[u] + 1).first;
      Set(1, 0, n, st[id[i]], make_pair(t, t * a[id[i]] % MOD));
    } else {
      long long ans = sum(1, 0, n, st[u], ft[u]).second;
      long long h =
          (u == 0 ? 1 : sum(1, 0, n, st[par[u]], st[par[u]] + 1).first);
      ans = ans * POW(h, MOD - 2) % MOD;
      cout << ans << '\n';
    }
  }
  return 0;
}