i,p,q;main(f){for(gets(&p);f&&~scanf("%d%d",&p,&q);i++)f=p-q*3e4<5e5;for(q=puts(f?"NO":"YES")+3;++q%7;printf("%d\n",i));}