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 + 2, mod = 1e9 + 7;
int p[maxn], q, a[maxn], ch[maxn], h = 2, w = 1;
long long tree[4 * maxn], lazy[4 * maxn];
vector<pair<pair<int, int>, int> > Q;
vector<int> e[maxn];
pair<int, int> seg[maxn];
long long power(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long temp = power(a, b / 2);
  temp = (temp * temp) % mod;
  if (b % 2 == 1) {
    temp = (temp * a) % mod;
  }
  return temp;
}
void dfs(int v) {
  seg[v].first = w;
  w++;
  for (auto u : e[v]) {
    dfs(u);
  }
  seg[v].second = w;
}
void shift(int node) {
  lazy[node * 2] = (lazy[node * 2] * lazy[node]) % mod;
  lazy[node * 2 + 1] = (lazy[node * 2 + 1] * lazy[node]) % mod;
  tree[node * 2] = (tree[node * 2] * lazy[node]) % mod;
  tree[node * 2 + 1] = (tree[node * 2 + 1] * lazy[node]) % mod;
  lazy[node] = 1;
}
void upd(int s, int f, int x, int y, int node = 1, int L = 1, int R = h) {
  if (f <= L || R <= s) {
    return;
  }
  if (s <= L && R <= f) {
    lazy[node] = lazy[node] * x % mod * power(y, mod - 2) % mod;
    tree[node] = (tree[node] * x) % mod;
    tree[node] = (tree[node] * power(y, mod - 2)) % mod;
    return;
  }
  shift(node);
  int mid = (L + R) / 2;
  upd(s, f, x, y, node * 2, L, mid);
  upd(s, f, x, y, node * 2 + 1, mid, R);
  tree[node] = (tree[node * 2] + tree[node * 2 + 1]) % mod;
  return;
}
void change(int s, int x, int node = 1, int L = 1, int R = h) {
  if (L == s && R - 1 == L) {
    tree[node] = x;
    return;
  }
  if (s < L || R <= s) {
    return;
  }
  shift(node);
  int mid = (L + R) / 2;
  change(s, x, node * 2, L, mid);
  change(s, x, node * 2 + 1, mid, R);
  tree[node] = (tree[node * 2] + tree[node * 2 + 1]) % mod;
  return;
}
long long query(int s, int f, int node = 1, int L = 1, int R = h) {
  if (s <= L && R <= f) {
    return tree[node];
  }
  if (f <= L || R <= s) {
    return 0;
  }
  shift(node);
  int mid = (L + R) / 2;
  long long t1, t2;
  t1 = query(s, f, node * 2, L, mid);
  t2 = query(s, f, node * 2 + 1, mid, R);
  return (t1 + t2) % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 4 * maxn; i++) {
    lazy[i] = 1;
  }
  cin >> p[1] >> q;
  for (int i = 1; i <= q; i++) {
    int temp1;
    cin >> temp1;
    if (temp1 == 1) {
      int temp2, temp3;
      cin >> temp3 >> temp2;
      Q.push_back({{h, temp3}, 1});
      e[temp3].push_back(h);
      p[h] = temp2;
      h++;
    } else {
      int temp2;
      cin >> temp2;
      Q.push_back({{temp2, 0}, 2});
    }
  }
  dfs(1);
  change(1, p[1]);
  for (auto tmp : Q) {
    int v1 = tmp.first.first;
    int v2 = tmp.first.second;
    if (tmp.second == 1) {
      long long mas = query(seg[v2].first, seg[v2].first + 1);
      mas = (mas * power(p[v2], mod - 2)) % mod;
      change(seg[v1].first, (mas * p[v1] % mod));
      upd(seg[v2].first, seg[v2].second, ch[v2] + 2, ch[v2] + 1);
      ch[v2]++;
    } else {
      long long mas = query(seg[v1].first, seg[v1].first + 1);
      mas = (mas * power(p[v1], mod - 2)) % mod;
      long long res = query(seg[v1].first, seg[v1].second);
      cout << res * power(mas, mod - 2) % mod * (ch[v1] + 1) % mod << endl;
    }
  }
  return 0;
}