/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package sepchallenge13;
import java.io.IOException;
/**
*
* @author puneet
*/
class MlChef {
int s[][],inf[][],n,h[],i,j,k,a,x,q,l,c[];
h=new int[n+1];
c=new int[n+1];
s=new int[n+1][n+1];
inf=new int[n+1][n+1];
for(i=0;i<n;i++)
s[0][i]=i+1;
s[0][n]=n;
inf[0][n]=0;
for(i=1;i<=n;i++)
{
tmp=in.readLine().split(" ");
if(j!=0)
{
inf[i][inf[i][n]++]=j;
s[j][s[j][n]++]=i;
}
}
for(i=n-1;i>=1;i--)
{
if(s[i][0]!=0)
{
for(j=1;j<i;j++)
{
for(k=0;k<s[j][n];k++)
{
if(s[j][k]==i)
{
for(l=0;l<s[i][n];l++)
{
s[j][s[j][n]++]=s[i][l];
}
break;
}
}
}
}
}
for(i=0;i<=n;i++)
c[i]=s[i][n];
for(i=1;i<=n;i++)
{
if(inf[i][0]!=0)
{
for(j=n;j>i;j--)
{
for(k=0;k<inf[j][n];k++)
{
if(inf[j][k]==i)
{
for(l=0;l<inf[i][n];l++)
{
inf[j][inf[j][n]++]=inf[i][l];
}
break;
}
}
}
}
}
// for(i=0;i<=n;i++)
// {
// for(j=0;j<inf[i][n];j++)
// System.out.print(inf[i][j]+" ");
// System.out.println();
// }
while(q>0)
{
tmp=in.readLine().split(" ");
if("1".equals(tmp[0]))
{
for(i=0;i<c[a] && s[a][n]>0;i++)
{
if(h[s[a][i]]>0)
{
h[s[a][i]]=h[s[a][i]]-x;
if(h[s[a][i]]<=0)
{
for(j=0;j<inf[s[a][i]][n];j++)
{
s[inf[s[a][i]][j]][n]--;
//s[0][n]--;
}
s[0][n]--;
}
}
}
}
else
{
// for(j=1;j<=n;j++)
// System.out.print(h[j]+" ");
}
q--;
}
}
}
LyoKICogVG8gY2hhbmdlIHRoaXMgdGVtcGxhdGUsIGNob29zZSBUb29scyB8IFRlbXBsYXRlcwogKiBhbmQgb3BlbiB0aGUgdGVtcGxhdGUgaW4gdGhlIGVkaXRvci4KICovCi8vcGFja2FnZSBzZXBjaGFsbGVuZ2UxMzsKCmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwoKLyoqCiAqCiAqIEBhdXRob3IgcHVuZWV0CiAqLwogY2xhc3MgTWxDaGVmIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBJT0V4Y2VwdGlvbiB7CiAgICAgICAgaW50IHNbXVtdLGluZltdW10sbixoW10saSxqLGssYSx4LHEsbCxjW107CiAgICAgICAgamF2YS5pby5CdWZmZXJlZFJlYWRlciBpbiA9IG5ldyBqYXZhLmlvLkJ1ZmZlcmVkUmVhZGVyIChuZXcgamF2YS5pby5JbnB1dFN0cmVhbVJlYWRlciAoU3lzdGVtLmluKSk7CiAgICAgICAgbj1JbnRlZ2VyLnBhcnNlSW50KGluLnJlYWRMaW5lKCkpOwogICAgICAgIGg9bmV3IGludFtuKzFdOwogICAgICAgIGM9bmV3IGludFtuKzFdOwogICAgICAgIHM9bmV3IGludFtuKzFdW24rMV07CiAgICAgICAgaW5mPW5ldyBpbnRbbisxXVtuKzFdOwogICAgICAgIGZvcihpPTA7aTxuO2krKykKICAgICAgICAgICAgc1swXVtpXT1pKzE7CiAgICAgICAgc1swXVtuXT1uOwogICAgICAgIGluZlswXVtuXT0wOwogICAgICAgIFN0cmluZyB0bXBbXTsKICAgICAgICBmb3IoaT0xO2k8PW47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgdG1wPWluLnJlYWRMaW5lKCkuc3BsaXQoIiAiKTsKICAgICAgICAgICAgaFtpXT1JbnRlZ2VyLnBhcnNlSW50KHRtcFswXSk7CiAgICAgICAgICAgIGo9SW50ZWdlci5wYXJzZUludCh0bXBbMV0pOwogICAgICAgICAgICBpZihqIT0wKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbmZbaV1baW5mW2ldW25dKytdPWo7CiAgICAgICAgICAgICAgICBzW2pdW3Nbal1bbl0rK109aTsKICAgICAgICAgICAgfSAgICAgICAgICAgICAgIAogICAgICAgIH0KICAgICAgICBmb3IoaT1uLTE7aT49MTtpLS0pCiAgICAgICAgewogICAgICAgICAgICBpZihzW2ldWzBdIT0wKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3Ioaj0xO2o8aTtqKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZm9yKGs9MDtrPHNbal1bbl07aysrKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYoc1tqXVtrXT09aSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGw9MDtsPHNbaV1bbl07bCsrKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNbal1bc1tqXVtuXSsrXT1zW2ldW2xdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yKGk9MDtpPD1uO2krKykKICAgICAgICAgICAgY1tpXT1zW2ldW25dOwogICAgICAgIGZvcihpPTE7aTw9bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBpZihpbmZbaV1bMF0hPTApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZvcihqPW47aj5pO2otLSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBmb3Ioaz0wO2s8aW5mW2pdW25dO2srKykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmKGluZltqXVtrXT09aSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGw9MDtsPGluZltpXVtuXTtsKyspCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5mW2pdW2luZltqXVtuXSsrXT1pbmZbaV1bbF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KLy8gICAgICAgIGZvcihpPTA7aTw9bjtpKyspCi8vICAgICAgICB7Ci8vICAgICAgICAgICAgZm9yKGo9MDtqPGluZltpXVtuXTtqKyspCi8vICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoaW5mW2ldW2pdKyIgIik7Ci8vICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCk7Ci8vICAgICAgICB9CiAgICAgICAgcT1JbnRlZ2VyLnBhcnNlSW50KGluLnJlYWRMaW5lKCkpOwogICAgICAgIHdoaWxlKHE+MCkKICAgICAgICB7CiAgICAgICAgICAgIHRtcD1pbi5yZWFkTGluZSgpLnNwbGl0KCIgIik7CiAgICAgICAgICAgIGE9SW50ZWdlci5wYXJzZUludCh0bXBbMV0pOwogICAgICAgICAgICBpZigiMSIuZXF1YWxzKHRtcFswXSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHg9SW50ZWdlci5wYXJzZUludCh0bXBbMl0pOwogICAgICAgICAgICAgICAgZm9yKGk9MDtpPGNbYV0gJiYgc1thXVtuXT4wO2krKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZihoW3NbYV1baV1dPjApICAgCiAgICAgICAgICAgICAgICAgICAgeyAgIAogICAgICAgICAgICAgICAgICAgICAgICBoW3NbYV1baV1dPWhbc1thXVtpXV0teDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYoaFtzW2FdW2ldXTw9MCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yKGo9MDtqPGluZltzW2FdW2ldXVtuXTtqKyspCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc1tpbmZbc1thXVtpXV1bal1dW25dLS07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9zWzBdW25dLS07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzWzBdW25dLS07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7Ci8vICAgICAgICAgICAgICAgICBmb3Ioaj0xO2o8PW47aisrKQovLyAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoaFtqXSsiICIpOwogICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihzW2FdW25dKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxLS07CiAgICAgICAgfQogICAgfQp9