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 inft = 1000000009;
const int mod = 1000000007;
const int MAXN = 1000006;
struct node {
  node *c[2], *p;
  int val, val2, mnoz, mn, ans, anss;
  bool hasp() { return p && (p->c[0] == this || p->c[1] == this); }
  int dir(node *n) { return c[0] != n; }
  void upd() {
    int ansl = c[0] ? c[0]->ans : 0;
    int ansr = c[1] ? c[1]->ans : 0;
    int mnl = c[0] ? c[0]->mn : 1;
    int mnr = c[1] ? c[1]->mn : 1;
    mn = 1LL * mnoz * mnl % mod * mnr % mod;
    anss = (1LL * (0LL + val + val2 + ansr) * mnoz) % mod;
    ans = (ansl + (1LL * (0LL + val + val2 + ansr) * mnoz % mod * mnl)) % mod;
  }
  void push() {}
  void pull() {}
};
void rot(node *n, int d) {
  node *m = n->c[d];
  if ((n->c[d] = m->c[!d])) n->c[d]->p = n;
  m->c[!d] = n;
  if (n->hasp()) n->p->c[n->p->dir(n)] = m;
  m->p = n->p;
  n->p = m;
  n->upd();
  m->upd();
}
void splay(node *n) {
  n->pull();
  while (n->hasp()) {
    node *p1 = n->p, *p2 = p1->p;
    if (!p1->hasp()) return rot(p1, p1->dir(n));
    int d1 = p1->dir(n), d2 = p2->dir(p1);
    if (d1 == d2) swap(p1, p2);
    rot(p1, d1);
    rot(p2, d2);
  }
}
void activate(node *n) {
  node *on = n, *m = NULL;
  for (; n; n = n->p) {
    splay(n);
    if (n->c[1]) n->val2 = (n->val2 + n->c[1]->ans) % mod;
    n->c[1] = m;
    if (n->c[1]) n->val2 = (n->val2 - n->c[1]->ans + mod) % mod;
    n->upd();
    m = n;
  }
  splay(on);
}
void link(node *n, node *m) {
  splay(n);
  assert(!n->c[0]);
  activate(m);
  n->c[0] = m;
  m->p = n;
  m->mnoz++;
  m->upd();
  n->upd();
}
node MEM[210000];
void solve() {
  int v0, q, next = 1;
  scanf("%d%d", &v0, &q);
  MEM[0].val = v0;
  MEM[0].mnoz = 1;
  MEM[0].upd();
  for (int qq = 0; qq < (q); ++qq) {
    int tt;
    scanf("%d", &tt);
    if (tt == 1) {
      int p, v;
      scanf("%d%d", &p, &v);
      p--;
      MEM[next].val = v;
      MEM[next].mnoz = 1;
      link(&MEM[next], &MEM[p]);
      next++;
    }
    if (tt == 2) {
      int p;
      scanf("%d", &p);
      p--;
      activate(&MEM[p]);
      printf("%d\n", MEM[p].anss);
    }
  }
}
int main() {
  int te = 1;
  for (int ti = 0; ti < (te); ++ti) solve();
  return 0;
}