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;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
int const N = 2e5 + 20, mod = 1e9 + 7;
int q, n, tp[N], p[N], x[N], val[N], deg[N];
int tme, st[N], ft[N];
vector<int> g[N];
struct node {
  int sum, mul;
  node() : sum(0), mul(1) {}
} seg[N << 2];
inline void rel(int x) {
  if (x < 0) x += mod;
  if (x >= mod) x -= mod;
}
inline int pw(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
inline int inv(int x) { return pw(x, mod - 2); }
void pre_dfs(int v) {
  st[v] = tme++;
  for (int u : g[v]) pre_dfs(u);
  ft[v] = tme;
}
inline int get(int v) { return 1ll * seg[v].sum * seg[v].mul % mod; }
inline void pull(int v) {
  int lc = v << 1, rc = lc | 1;
  seg[v].sum = get(lc) + get(rc);
  rel(seg[v].sum);
}
void modify(int p, int val, int v = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[v].sum = val;
    return;
  }
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  if (p < mid)
    modify(p, val, lc, s, mid);
  else
    modify(p, val, rc, mid, e);
  pull(v);
}
void mul(int l, int r, int val, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    seg[v].mul = 1ll * seg[v].mul * val % mod;
    return;
  }
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  mul(l, r, val, lc, s, mid);
  mul(l, r, val, rc, mid, e);
  pull(v);
}
int get_sum(int l, int r, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) return 0;
  if (l <= s && e <= r) return get(v);
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  int ret = get_sum(l, r, lc, s, mid) + get_sum(l, r, rc, mid, e);
  rel(ret);
  ret = 1ll * ret * seg[v].mul % mod;
  return ret;
}
int get_mul(int p, int v = 1, int s = 0, int e = n) {
  int ret = seg[v].mul;
  if (s + 1 == e) return ret;
  int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
  if (p < mid)
    ret = 1ll * ret * get_mul(p, lc, s, mid) % mod;
  else
    ret = 1ll * ret * get_mul(p, rc, mid, e) % mod;
  return ret;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> val[0] >> q;
  n = 1;
  for (int i = 0; i < q; i++) {
    cin >> tp[i] >> p[i];
    p[i]--;
    if (tp[i] == 1) {
      x[i] = n++;
      cin >> val[x[i]];
      g[p[i]].push_back(x[i]);
    }
  }
  pre_dfs(0);
  deg[0] = 1;
  modify(st[0], val[0]);
  for (int i = 0; i < q; i++) {
    if (tp[i] == 1) {
      deg[x[i]] = 1;
      modify(st[x[i]], val[x[i]]);
      mul(st[p[i]], ft[p[i]], 1ll * inv(deg[p[i]]) * (++deg[p[i]]) % mod);
    } else {
      cout << 1ll * get_sum(st[p[i]], ft[p[i]]) * inv(get_mul(st[p[i]])) % mod *
                  deg[p[i]] % mod
           << '\n';
    }
  }
}