fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define uniq(x) x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
  4. #define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr //Upper value search;
  5. #define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr //Lower value search;
  6. #define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
  7. #define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
  8. #define PI acos(-1.0)//PI Calculation
  9. #define LL long long
  10. #define AND(a,b) ((a) & (b))
  11. #define OR(a,b) ((a)|(b))
  12. #define XOR(a,b) ((a) ^ (b))
  13. #define mp make_pair
  14. #define sqr(x) ((x)*(x))
  15. #define sqrt(x) sqrt(1.0*(x))
  16. #define INF_MAX 2147483647
  17. #define INF_MIN -2147483647
  18. #define MX 1000005
  19. #define MOD 1000000007
  20. template<typename T> T POW(T b,T p) //Pow calculation
  21. {
  22. T r=1;
  23. while(p)
  24. {
  25. if(p&1)r=(r*b);
  26. b=(b*b);
  27. p>>=1;
  28. }
  29. return r;
  30. }
  31.  
  32. template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
  33. {
  34. T r=1;
  35. while(p)
  36. {
  37. if(p&1)r=(r*b)%m;
  38. b=(b*b)%m;
  39. p>>=1;
  40. }
  41. return r;
  42. }
  43.  
  44. //||--------------------------->||Main_Code_Start_Here||<---------------------------------||
  45. int main()
  46. {
  47. //freopen("a.in", "r", stdin);
  48. //freopen("a.out", "w", stdout);
  49. int test;
  50. string s;
  51. cin>>test;
  52. while(test--)
  53. {
  54. cin>>s;
  55. for(int i=0; i<s.size()/2; i++)
  56. {
  57. if(s[i]=='.')
  58. {
  59. if(s[i]==s[s.size()-1-i])
  60. {
  61. s[i]='a';
  62. s[s.size()-1-i]='a';
  63. }
  64. }
  65. }
  66. if(s.size()%2) s[s.size()/2]='a';
  67. //cout<<"s = "<<s<<endl;
  68.  
  69.  
  70. for(int i=0; i<s.size()/2; i++)//left string checking
  71. {
  72. if(s[i]=='.')
  73. {
  74. s[i]=s[s.size()-1-i];
  75. }
  76. }
  77.  
  78.  
  79.  
  80. for(int i=s.size()-1,k=0; i>s.size()/2; i--,k++)//Right string checking
  81. {
  82. if(s[i]=='.')
  83. {
  84. s[i]=s[k];
  85. }
  86. }
  87.  
  88.  
  89.  
  90.  
  91.  
  92. //cout<<" ss = "<<s<<endl;
  93.  
  94. bool flag=true;
  95. for(int i=0; i<s.size()/2; i++)
  96. {
  97. if(s[i]!=s[s.size()-1-i])
  98. {
  99. flag=false;
  100. }
  101. }
  102.  
  103. if(flag==false) cout<<"-1"<<endl;
  104. else cout<<s<<endl;
  105.  
  106.  
  107. }
  108. }
  109.  
  110.  
  111.  
Success #stdin #stdout 0s 3476KB
stdin
3
a.ba
cb.bc
a.b
stdout
abba
cbabc
-1