#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class ABBADiv1 { public:
	string canObtain(string initial, string target)
	{
		return can(target, initial) ? "Possible" : "Impossible";
	}

	map<string, bool> memo;
	bool can(const string& X, const string& S)
	{
		if(X == S)
			return true;
		if(X.size() < S.size())
			return false;
		if(memo.count(X))
			return memo[X];
		if(X[X.size()-1] == 'A' && can(X.substr(0, X.size()-1), S)) return memo[X] = true;
		if(X[0] == 'B' && can(rev(X.substr(1, X.size())), S)) return memo[X] = true;
		return memo[X] = false;
	}

	string rev(const string& x) { return string(x.rbegin(), x.rend()); }
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, ABBADiv1().canObtain(initial, target));}
int main(){

CASE(0)
	string initial = "A"; 
	string target = "BABA"; 
	string _ = "Possible"; 
END
CASE(1)
	string initial = "BAAAAABAA"; 
	string target = "BAABAAAAAB"; 
	string _ = "Possible"; 
END
CASE(2)
	string initial = "A"; 
	string target = "ABBA"; 
	string _ = "Impossible"; 
END
CASE(3)
	string initial = "AAABBAABB"; 
	string target = "BAABAAABAABAABBBAAAAAABBAABBBBBBBABB"; 
	string _ = "Possible"; 
END
CASE(4)
	string initial = "AAABAAABB"; 
	string target = "BAABAAABAABAABBBAAAAAABBAABBBBBBBABB"; 
	string _ = "Impossible"; 
END
/*
CASE(5)
	string initial = ; 
	string target = ; 
	string _ = ; 
END
CASE(6)
	string initial = ; 
	string target = ; 
	string _ = ; 
END
*/
}
// END CUT HERE
