#include <iostream> using namespace std; int main() { int t; int n,d,l,f,m; while(cin>>t) { for(int a=1;a<=t;a++) { cin>>n>>d>>l>>f; m=n%d; for(int j=1;j<=l;j++) { m*=7;m%=d; } cout<<"Problem set "<<a<<": "<<n<<" / "<<d<<", base 7 digits "<<l<<" through "<<f<<": "; for(int j=l;j<=f;j++) { m*=7;printf("%d",m/d); m%=d; } cout<<endl; } } }