#include <stdio.h>
int main ()
{
int n , k ,x ,t ,i ,p ;
scanf ("%d",&t) ;
for (i=1 ; i<=t ;i++)
{
scanf ("%d %d %d",&n , &k , &p) ;
x =(k +p) %n ;
if (x == 0) printf ("Case %d: %d\n",i ,n) ;
else printf ("Case %d: %d\n",i ,x ) ;
}
return 0;
}
int main ()
{
int n , k ,x ,t ,i ,p ;
scanf ("%d",&t) ;
for (i=1 ; i<=t ;i++)
{
scanf ("%d %d %d",&n , &k , &p) ;
x =(k +p) %n ;
if (x == 0) printf ("Case %d: %d\n",i ,n) ;
else printf ("Case %d: %d\n",i ,x ) ;
}
return 0;
}