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 double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
T sqr(const T &x) {
  return x * x;
}
template <class T>
T lowbit(const T &x) {
  return (x ^ (x - 1)) & x;
}
template <class T>
int countbit(const T &n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
void ckmin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
void ckmax(T &a, const T &b) {
  if (b > a) a = b;
}
const int maxn = (1 << 20);
const int MOD = 1000000007;
int n;
int m;
int a[maxn];
vector<int> g[maxn];
int v0[maxn], v1[maxn], v2[maxn], v3[maxn];
int sizeq;
int q[maxn], s[maxn], t[maxn];
int w[maxn];
int mul[maxn * 4];
int sum[maxn * 4];
void dfs(int p) {
  s[p] = sizeq;
  q[sizeq++] = p;
  for (int i = 0; i < (((int)(g[p].size()))); ++i) dfs(g[p][i]);
  t[p] = sizeq - 1;
}
void push(int id) {
  if (mul[id] == 1) return;
  int x = mul[id];
  mul[id] = 1;
  mul[id * 2 + 1] =
      ((int)((long long)(mul[id * 2 + 1]) * (long long)(x) % MOD));
  mul[id * 2 + 2] =
      ((int)((long long)(mul[id * 2 + 2]) * (long long)(x) % MOD));
  sum[id * 2 + 1] =
      ((int)((long long)(sum[id * 2 + 1]) * (long long)(x) % MOD));
  sum[id * 2 + 2] =
      ((int)((long long)(sum[id * 2 + 2]) * (long long)(x) % MOD));
}
void pop(int id) {
  sum[id] = ((int)((long long)(mul[id]) *
                   (long long)(sum[id * 2 + 1] + sum[id * 2 + 2]) % MOD));
}
void add_one(int id, int s, int t, int key) {
  if (s == t) {
    sum[id] = ((int)((long long)(mul[id]) * (long long)(a[s]) % MOD));
    return;
  }
  push(id);
  int m = (s + t) / 2;
  if (key <= m)
    add_one(id * 2 + 1, s, m, key);
  else
    add_one(id * 2 + 2, m + 1, t, key);
  pop(id);
}
int inverse(int x) {
  int e = MOD - 2;
  int r = 1;
  for (; e > 0; e /= 2) {
    if (e & 1) r = ((int)((long long)(r) * (long long)(x) % MOD));
    x = ((int)((long long)(x) * (long long)(x) % MOD));
  }
  return r;
}
void init(int id, int s, int t) {
  if (s == t) {
    mul[id] = 1;
    sum[id] = ((int)((long long)(mul[id]) * (long long)(a[q[s]]) % MOD));
    return;
  }
  mul[id] = 1;
  int m = (s + t) / 2;
  init(id * 2 + 1, s, m);
  init(id * 2 + 2, m + 1, t);
  pop(id);
}
void update(int id, int s, int t, int l, int r, int d) {
  if (s >= l && t <= r) {
    mul[id] = ((int)((long long)(mul[id]) * (long long)(d) % MOD));
    sum[id] = ((int)((long long)(sum[id]) * (long long)(d) % MOD));
    return;
  }
  push(id);
  int m = (s + t) / 2;
  if (l <= m) update(id * 2 + 1, s, m, l, r, d);
  if (m < r) update(id * 2 + 2, m + 1, t, l, r, d);
  pop(id);
}
int get_one(int id, int s, int t, int key) {
  if (s == t) return mul[id];
  push(id);
  int m = (s + t) / 2;
  return (key <= m) ? get_one(id * 2 + 1, s, m, key)
                    : get_one(id * 2 + 2, m + 1, t, key);
}
int get_sum(int id, int s, int t, int l, int r) {
  if (s >= l && t <= r) return sum[id];
  push(id);
  int m = (s + t) / 2;
  int ret = 0;
  if (l <= m) ret += get_sum(id * 2 + 1, s, m, l, r);
  if (m < r) ret += get_sum(id * 2 + 2, m + 1, t, l, r);
  if (ret >= MOD) ret -= MOD;
  return ret;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  n = 1;
  cin >> a[0] >> m;
  for (int i = 0; i < (m); ++i) {
    cin >> v0[i] >> v1[i];
    if (v0[i] == 1) cin >> v2[i];
  }
  for (int i = 0; i < (m); ++i)
    if (v0[i] == 1) {
      --v1[i];
      g[v1[i]].push_back(n);
      v3[i] = n;
      a[n] = v2[i];
      n++;
    } else {
      --v1[i];
    }
  sizeq = 0;
  dfs(0);
  for (int i = 0; i < (n); ++i) w[i] = ((int)(g[i].size())) + 1;
  init(0, 0, n - 1);
  for (int i = 0; i < (n); ++i) update(0, 0, n - 1, s[i], t[i], w[i]);
  for (int i = m - 1; i >= 0; i--)
    if (v0[i] == 1) {
      int key = v1[i];
      update(0, 0, n - 1, s[key], t[key],
             ((int)((long long)(inverse(w[key])) * (long long)((w[key] - 1)) %
                    MOD)));
      w[key]--;
      key = v3[i];
      update(0, 0, n - 1, s[key], t[key],
             ((int)((long long)(inverse(w[key])) * (long long)((w[key] - 1)) %
                    MOD)));
      w[key]--;
    } else {
      int key = v1[i];
      int val = get_one(0, 0, n - 1, s[key]);
      int ret = get_sum(0, 0, n - 1, s[key], t[key]);
      v2[i] = ((int)((long long)(inverse(val)) *
                     (long long)((
                         (int)((long long)(w[key]) * (long long)(ret) % MOD))) %
                     MOD));
    }
  for (int i = 0; i < (m); ++i)
    if (v0[i] == 2) printf("%d\n", v2[i]);
  return 0;
}