#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int long long
void file() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
// freopen("errors.txt", "w", stderr);
#endif
}
string s;
bool is_pali(string now) {
string co=now;
reverse(co.begin(), co.end());
return co==now;
}
int rec(int i=0,string now="") {
if (i==s.size()) {
if (now.size() && is_pali(now))
return 1;
return 0;
}
int a=rec(i+1,now+s[i]);
int b=rec(i+1,now);
return a+b;
}
void solve(){
cin>>s;
cout<<rec()<<endl;
}
signed main() {
file();
int off = 1;
cin>>off;
while (off--)
solve();
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCnZvaWQgZmlsZSgpIHsKI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIC8vIGZyZW9wZW4oImVycm9ycy50eHQiLCAidyIsIHN0ZGVycik7CiNlbmRpZgp9CnN0cmluZyBzOwpib29sIGlzX3BhbGkoc3RyaW5nIG5vdykgewogICAgc3RyaW5nIGNvPW5vdzsKICAgIHJldmVyc2UoY28uYmVnaW4oKSwgY28uZW5kKCkpOwogICAgcmV0dXJuIGNvPT1ub3c7Cn0KaW50IHJlYyhpbnQgaT0wLHN0cmluZyBub3c9IiIpIHsKICAgIGlmIChpPT1zLnNpemUoKSkgewogICAgICAgIGlmIChub3cuc2l6ZSgpICYmIGlzX3BhbGkobm93KSkKICAgICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9CiAgICBpbnQgYT1yZWMoaSsxLG5vdytzW2ldKTsKICAgIGludCBiPXJlYyhpKzEsbm93KTsKICAgIHJldHVybiBhK2I7Cn0Kdm9pZCBzb2x2ZSgpewogICAgY2luPj5zOwogICAgY291dDw8cmVjKCk8PGVuZGw7Cn0KCnNpZ25lZCBtYWluKCkgewogICAgZmlsZSgpOwogICAgaW50IG9mZiA9IDE7CiAgICBjaW4+Pm9mZjsKICAgIHdoaWxlIChvZmYtLSkKICAgICAgICBzb2x2ZSgpOwp9