#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct In
{
int ATI;
int DEF;
int HP;
int LEVEL;
}node[25],s[1<<20];
int ATI,DEF,HP,LEVEL,INATI,INDEF,INHP;
int cas;
int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
In Dfs(int p)
{
int r;
In now;
bool flag = false;
if(s[p].LEVEL != -1)
return s[p];
int i;
for(i = 0;i < cas;i++ )
{
r=1 << i;
if(r & p)
{
now = Dfs(p-(1<<i));
int a = max(now.ATI-node[i].DEF,1);
int b = max(node[i].ATI-now.DEF,1);
int c = now.HP-(node[i].HP/a-1+((node[i].HP%a)>0))*b;
int h = (now.LEVEL + node[i].LEVEL)/100;
if(c > 0)
c = c + INHP * (h-(now.LEVEL/100));
if(!flag || c > s[p].HP)
{
s[p].HP = c;
s[p].ATI = s[0].ATI + h * INATI;
s[p].DEF = s[0].DEF + h*INDEF;
s[p].LEVEL = (now.LEVEL + node[i].LEVEL);
flag = true;
}
}
}
return s[p];
}
int main()
{
while(scanf("%d%d%d%d%d%d",&s[0].ATI,&s[0].DEF,&s[0].HP,&INATI,&INDEF,&INHP) != EOF)
{
char name[25];
scanf("%d",&cas);
int i;
for(i = 0; i < cas;i++)
{
scanf("%s%d%d%d%d",&name,&node[i].ATI,&node[i].DEF,&node[i].HP,&node[i].LEVEL);
}
s[0].LEVEL = 0;
int last = (1 << cas) -1;
for(i = 1; i<= last ;i++)
s[i].LEVEL = -1;
In ans;
ans = Dfs(last);
if(ans.HP > 0)
printf("%d\n",ans.HP);
else
printf("Poor LvBu,his period was gone.\n");
}
return 0;
}