#include<stdio.h>
int main(){
long long int x,i,a,b,t,h,arm;
for(i=0;i<x;i++){
scanf("%lld %lld",&a
,&b
); if(a==0||b==0)
else{
t=1;
h=a+3;
arm=b+2;
while(1){
if(h>5&&arm>10){
h=h-2;
arm=arm-8;
t=t+2;
}else if(h>20&&arm<=10){
h=h-17;
arm=arm+7;
t=t+2;
}else {
break;
}
}
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKCl7CiAgICBsb25nIGxvbmcgaW50IHgsaSxhLGIsdCxoLGFybTsKICAgIHNjYW5mKCIlbGxkIiwmeCk7CiAgICBmb3IoaT0wO2k8eDtpKyspewogICAgICAgIHNjYW5mKCIlbGxkICVsbGQiLCZhLCZiKTsKICAgICAgICBpZihhPT0wfHxiPT0wKQogICAgICAgICBwcmludGYoIjBcbiIpOwogICAgICAgIGVsc2V7CiAgICAgICAgICAgIHQ9MTsKICAgICAgICAgICAgaD1hKzM7CiAgICAgICAgICAgIGFybT1iKzI7CiAgICAgICAgICAgIHdoaWxlKDEpewogICAgICAgICAgICAgICAgaWYoaD41JiZhcm0+MTApewogICAgICAgICAgICAgICAgICAgIGg9aC0yOwogICAgICAgICAgICAgICAgICAgIGFybT1hcm0tODsKICAgICAgICAgICAgICAgICAgICB0PXQrMjsKICAgICAgICAgICAgICAgIH1lbHNlIGlmKGg+MjAmJmFybTw9MTApewogICAgICAgICAgICAgICAgICAgIGg9aC0xNzsKICAgICAgICAgICAgICAgICAgICBhcm09YXJtKzc7CiAgICAgICAgICAgICAgICAgICAgdD10KzI7CiAgICAgICAgICAgICAgICB9ZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCIlbGxkXG4iLHQpOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0g