lets check this out,
//declarations
while(scanf("%d",&k)!=EOF)
{
for(i=0;;i++)
{
scanf("%d",&poly);
if(getchar()=='\n') break;
}
// rest of the code
}
//declarations
while(scanf("%d",&k)!=EOF)
{
for(i=0;;i++)
{
scanf("%d",&poly);
if(getchar()=='\n') break;
}
// rest of the code
}