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 N = 2 * 1e5 + 10, mod = 1e9 + 7;
int par[N], st[N], en[N], v[N], p[N], tim = 0, deg[N], t[N], val[N];
long long seg[4 * N], lazy[4 * N];
vector<int> adj[N];
int power(int a, int b) {
  if (b == 0) return 1;
  long long ret = power(a, b / 2);
  ret *= ret;
  ret %= mod;
  if (b % 2 == 1) ret *= a;
  ret %= mod;
  return ret;
}
void p_dfs(int x, int y = -1) {
  st[x] = tim++;
  par[x] = y;
  for (auto u : adj[x]) {
    if (u == y) continue;
    p_dfs(u, x);
  }
  en[x] = tim;
}
void shift(int id) {
  if (lazy[id] == 1) return;
  lazy[2 * id] *= lazy[id];
  lazy[2 * id] %= mod;
  seg[2 * id] *= lazy[id];
  seg[2 * id] %= mod;
  lazy[2 * id + 1] *= lazy[id];
  lazy[2 * id + 1] %= mod;
  seg[2 * id + 1] *= lazy[id];
  seg[2 * id + 1] %= mod;
  lazy[id] = 1;
  return;
}
void upd1(int id, int L, int R, int s, int e, int value) {
  if (L <= s && e <= R) {
    seg[id] *= value;
    seg[id] %= mod;
    lazy[id] *= value;
    lazy[id] %= mod;
    return;
  }
  if (L >= e || s >= R) return;
  int mid = (s + e) / 2;
  shift(id);
  upd1(2 * id, L, R, s, mid, value);
  upd1(2 * id + 1, L, R, mid, e, value);
  seg[id] = seg[2 * id] + seg[2 * id + 1];
  seg[id] %= mod;
  return;
}
void upd2(int id, int ind, int s, int e, int value) {
  if (e - s < 2) {
    seg[id] = value;
    return;
  }
  int mid = (s + e) / 2;
  shift(id);
  if (ind < mid)
    upd2(2 * id, ind, s, mid, value);
  else
    upd2(2 * id + 1, ind, mid, e, value);
  seg[id] = seg[2 * id] + seg[2 * id + 1];
  seg[id] %= mod;
  return;
}
int get(int id, int L, int R, int s, int e) {
  if (L <= s && e <= R) {
    return seg[id];
  }
  if (L >= e || s >= R) return 0;
  int mid = (s + e) / 2;
  shift(id);
  int ret = get(2 * id, L, R, s, mid);
  ret += get(2 * id + 1, L, R, mid, e);
  ret %= mod;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int v1, q, cnt = 2;
  cin >> v1 >> q;
  for (int i = 0; i < q; i++) {
    cin >> t[i];
    if (t[i] == 1)
      cin >> p[i] >> v[i];
    else
      cin >> v[i];
    if (t[i] == 1) {
      adj[p[i]].push_back(cnt);
      adj[cnt].push_back(p[i]);
      val[cnt] = v[i];
      cnt++;
    }
  }
  int n = cnt;
  adj[0].push_back(1);
  adj[1].push_back(0);
  p_dfs(0, -1);
  val[0] = 1;
  val[1] = v1;
  for (int i = 0; i < 4 * N; i++) lazy[i] = 1;
  upd2(1, st[1], 0, n, v1);
  upd2(1, st[0], 0, n, 1);
  cnt = 2;
  deg[0] = deg[1] = 1;
  for (int i = 0; i < q; i++) {
    if (t[i] == 2) {
      int u = v[i];
      long long ret = get(1, st[u], en[u], 0, n);
      long long ret2 = get(1, st[par[u]], st[par[u]] + 1, 0, n);
      ret2 *= power(val[par[u]], mod - 2);
      ret2 %= mod;
      ret *= power(ret2, mod - 2);
      ret %= mod;
      cout << ret << '\n';
    } else {
      long long value = deg[p[i]] + 1;
      upd1(1, st[p[i]], en[p[i]], 0, n, value);
      value = power(deg[p[i]], mod - 2);
      upd1(1, st[p[i]], en[p[i]], 0, n, value);
      long long ret = get(1, st[p[i]], st[p[i]] + 1, 0, n);
      ret *= power(val[p[i]], mod - 2);
      ret %= mod;
      ret *= v[i];
      ret %= mod;
      upd2(1, st[cnt], 0, n, ret);
      deg[cnt]++;
      deg[p[i]]++;
      cnt++;
    }
  }
}