1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 #include<string> 6 using namespace std; 7 8 const int maxn=2005; 9 int vis[maxn]; 10 11 int main() 12 { 13 int t,k; 14 string str; 15 cin>>t; 16 while(t--) 17 { 18 int j; 19 cin>>str>>k; 20 while(k--) 21 { 22 j=0; 23 while(j<str.size()-1&&str[j]<=str[j+1]) 24 j++; 25 str.erase(j,1); 26 } 27 j=0; 28 while(str[j]=='0') 29 j++; 30 str.erase(0,j); 31 if(str.size()==0) 32 cout<<"0"<<endl; 33 else 34 cout<<str<<endl; 35 } 36 return 0; 37 }