fork download
  1. #include<iostream>
  2. #include<string.h>
  3. using namespace std;
  4. int arr[26];
  5. int main(){
  6.  
  7. string s1, s2;
  8. int n;
  9. cin>>n;
  10. while(n--)
  11. {
  12. bool find = true;
  13.  
  14. cin>>s1>>s2;
  15. for(char c:s1)arr[c-'a']++;
  16. for(char c:s2)arr[c-'a']--;
  17. for(int i=0; i<26; i++)
  18. {
  19. if(arr[i]!=0)
  20. {cout<<"Impossible\n";
  21. bool find = false;
  22. break;
  23. }
  24. }
  25.  
  26. if(find) cout<<"Possible\n";
  27.  
  28. }
  29.  
  30.  
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5356KB
stdin
4
a a
ab ba
ring gnir
newt twan
stdout
Possible
Possible
Possible
Impossible
Possible