aboutsummaryrefslogtreecommitdiff
path: root/InfiniteReplacement.cpp
blob: 850e0ec79d1ae6f2a5c7d31664f708fc68cbefd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <algorithm>
#include<bits/stdc++.h>

using namespace std;

int main() {
  int tt;
  cin >> tt;
  string s, t;
  while (tt--) {
    cin >> s;
    cin >> t;
    if(t.find('a') != std::string::npos && t.length() > 1) {
      cout << "-1" << endl;
    }
    else if(t.find('a') != std::string::npos && t.length() == 1) {
      cout << "1" << endl;
    }
    else {
      long long ans = pow(2, s.length());
      cout << ans << endl;
    }
  }

  return 0;
}