#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
string s;
cin >> s;
int h = s[0] - '0';
h = h*10 + (s[1] - '0');
int m = s[3] - '0';
m = m*10 + (s[4] - '0');
while(1)
{
if(m == 59)
{
h++;
m = -1;
if(h == 24)
h = 0;
}
m++;
if(h == 0)
{
string r1 = to_string(m);
string r2 = r1;
reverse(r2.begin(), r2.end());
if(r1 == r2)
{
cout << "00:";
if(m < 10)
cout << "0";
cout << m << "\n";
break;
}
}
else
{
string r1 = to_string(h);
string r2 = "";
if(m < 10)
{
r2 = to_string(m);
r2 = "0" + r2;
}
else
r2 = to_string(m);
string r = r1 + r2;
string ch = r;
reverse(ch.begin(), ch.end());
if(r == ch)
{
if(h < 10)
cout << "0";
cout << h << ":";
if(m < 10)
cout << "0";
cout << m << "\n";
break;
}
}
}
}
return 0;
}
Comments
Post a Comment