#include<stdio.h>#include<string.h>#include<queue>#include<math.h>#include<algorithm>using namespace std;int m,s,k,flag;int xi[330];int yi[330];int book[330][330];struct data {int x; int y;int s;double l;};void bfs(int x,int y,int step,double l){queue<data>Q;data now,temp;now.x = x;now.y = y;now.s = step;now.l = 0;book[x][y] = 1;Q.push(now);while(!Q.empty()){now = Q.front();Q.pop();if(now.l == s*s){printf("%d\n",now.s);flag = 1;break;}for(int i=0; i<m; i++){int dx = now.x + xi[i];int dy = now.y + yi[i];int dl = (dx*dx) + (dy*dy); if(dx >= 0 && dy >= 0 && dl <= s*s){if(!book[dx][dy]){book[dx][dy] = 1;temp.x = dx;temp.y = dy;temp.l = dl;temp.s = now.s+1;Q.push(temp); }}}}if(flag == 0)printf("not possible\n");}int main(){int r;scanf("%d",&r);while(r--){scanf("%d %d",&m,&s);for(int i=0; i<m; i++)scanf("%d %d",&xi[i],&yi[i]);memset(book,0,sizeof(book));bfs(0,0,0,0);}}