include [HTML_REMOVED]
int main()
{
int r,y,g;
scanf(“%d %d %d”,&r,&y,&g);
int n;
scanf(“%d”,&n);
int time = 0;
while(n!=0)
{
int k = 0,t = 0;
scanf(“%d %d”,&k,&t);
switch(k)
{
case 0:
time += t;
break;
case 1:
time += t;
break;
case 2:
time += (t + r);
case 3:
break;
}
n–;
}
printf(“%d”,time);
}