#include using namespace std; typedef long long ll; ll n,a,b,cnt; int main(void){ cin>>n; for(int i=0;i>a>>b; if(b==1){ cout<1){ a-=L; L*=b; cnt++; } cout<