include <bits/stdc++.h>
using namespace std;
bool check(string &x, string &y)
{
bool flag = true;
for (int i = 0; i < x.length(); i++)
{
if (y[i] == x[i])
{
flag = false;
break;
}
}
if (flag)
return true;
return false;
}
int main()
{
int test;
cin >> test;
while (test–)
{
string s = “codechef”;
string y;
cin >> y;
bool fl = true;
bool flag = check(s, y);
if (flag)
cout << y << endl;
else
{
//cout << "Some work" << endl;
int i = 1;
while (i <= 7)
{
char last = y[7];
for (int i = y.length() - 2; i >= 0; i--)
{
y[i + 1] = y[i];
// cout << y << endl;
}
y[0] = last;
bool cha = check(s, y);
if (cha)
{
fl = false;
cout << y << endl;
break;
}
++i;
// cout << "i " << i << endl;
}
if (fl)
cout << -1 << endl;
}
}
}
So i am doing a right shift to solve the issue !