#include<iostream>
#include 
<string>
using namespace std;

string str;;
__int64 N;
int k;
int result[100];
int index = 0;

int main()
{
    
int t,i;
    cin
>>t;
    
while(t--)
    {
        cin 
>> k;
        cin 
>> str;
        cin 
>> N;
        
for(i = k-1;i >= 0--i)
        {
            
if((N%2==1|| (N%2 == -1))
            {
//奇数
                
                
if(str[i] == 'p')
                {
//减1
                    N-=1;
                    N
/=2;
                }
                
else if (str[i] == 'n')
                {
//加1
                    N+=1;
                    N
/=2;
                }
                result[index
++= 1;
            }
            
else
            {
//偶数
                N/=2;
                result[index
++= 0;
            }
        }
        
if(N != 0)
        {
            cout
<<"Impossible";
        }
        
else
        {
            
for(i = k-1; i >= 0--i)
            {
                cout 
<< result[i];
            }
        }
        cout 
<< endl;
        index 
= 0;
    }
    
return 0;
}

相关文章:

  • 2021-11-02
  • 2021-06-05
  • 2022-12-23
  • 2022-01-15
  • 2021-11-10
  • 2021-06-10
  • 2022-01-18
  • 2022-01-11
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2021-11-05
  • 2022-03-01
  • 2022-12-23
相关资源
相似解决方案