#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
char* substring(char*, int, int);
//je
int main()
{
   char str[10], *temp1,*temp2;
   int position, length,a,b,bandera;
   gets(str);
   temp1= substring( str,0,2);
   temp2= substring( str,4,2);
   a=atoi(temp1);
   b=atoi(temp2);
   bandera=0;
   while (bandera==0){
		b=b+1;
		if (b==60){
			a=a+1;
			b=00;
			if(a==24){
				a=00;
			}
		}
        sprintf(temp1,"%02d",a);
        sprintf(temp2,"%02d",b);
        if(temp1[0]==temp2[1] && temp1[1]==temp2[0]){
			printf("%s:%s",temp1,temp2);
			bandera=1;
        }

   }
   return 0;
}

char *substring(char *str, int position, int length)
{
   char *pointer;
   int c;
   pointer = malloc(length+1);
        if (pointer == NULL){
            printf("Unable to allocate memory.\n");
            exit(EXIT_FAILURE);
   }
        for (c = 0 ; c < position -1 ; c++)
            str++;

        for (c = 0 ; c < length ; c++){
            *(pointer+c) = *str;
            str++;
   }

   *(pointer+c) = '\0';

   return pointer;

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
    int palindromo[16][2]={{00,00},{01,10},{02,20},{03,30},{04,40},{05,50},{10,01},{11,11},{12,21},{13,31},{14,41},{15,51},{20,02},{21,12},{22,22},{23,32}};
int main() {
    char HHMM[5];
    scanf("%s", &HHMM);
    int hora, pos;
    int minuto;
    char aux[4];
    memcpy(aux,&HHMM[0],2);
    aux[3]='\0';
    hora= atoi(aux);
    memcpy(aux, &HHMM[3],2);
    aux[3]='\0';
    minuto= atoi(aux);
    pos=time(hora, minuto);
    if(palindromo[pos][0]<10)
        printf("0%d:", palindromo[pos][0]);
    else
        printf("%d:", palindromo[pos][0]);
    if (palindromo[pos][1]<10)
        printf("0%d", palindromo[pos][1]);
    else
        printf("%d", palindromo[pos][1]);

    return 0;
}
int time(int hora, int min){
    int i=0;
    for(i=0 ; i<16; i++){
        if(hora <= palindromo[i][0]){
            if( hora==23 && min>=palindromo[i][1])
                return i=0;
            if( hora < palindromo[i][0] && min>=palindromo[i][1]){
                return i;
            }else{
                if(min < palindromo[i][1] )
                    return i;
                else
                    return i+1;
            }
        }else{
            if(hora==palindromo[i][0] && min<palindromo[i][1])
                return i;
        }
    }
}

//Code forces 108A
#include<stdio.h>
int main()
{
    int hh,mm,temph,tempm;
    scanf("%d:%d",&hh,&mm);
    while(1)
    {
        mm++;
        if(mm==60){hh++;mm=0;}
        if(hh==24) hh=0;
        temph=hh/10;
        tempm=mm/10;
        if((tempm==hh%10) && (temph==mm%10)){printf("%02d:%02d",hh,mm);return 0;}
    }
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int rev(int a){
    return (a%10)*10+a/10;
}
int main()
{
    int i,h,m;
    scanf("%d:%d",&h,&m);
    if(rev(h)<=(m)){
        if(h==23)printf("00:00");
        else if(h>=0&&h<=5)printf("0%d:%d",h+1,rev(h+1));
        else if (h>=6&&h<=9)printf("10:01");
        else if(h>=15&&h<=19)printf("20:02");
        else printf("%d:%d",h+1,rev(h+1));
    }
    else {
        if(h>=0&&h<=5)printf("0%d:%d",h,rev(h));
        else if (h>=6&&h<=9)printf("10:01");
        else if(h>=16&&h<=19)printf("20:02");
        else printf("%d:%d",h,rev(h));
    }

    return 0;
}

/*
 * =====================================================================================
 *
 *       Filename:  4.c
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  05/14/2013 09:36:55 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Devansh T Shah (@d),
 *        Company:  IIIT Hyd
 *
 * =====================================================================================
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define si(n) scanf("%d",&n)
#define rep(i,n) for(i=0;i<n;i++)
#define REP(i,a,b) for(i=a;i<b;i++)
#define nl printf("\n")
#define sp printf(" ")
#define dbg(n) printf(" #n -- > %d\n",n)
#define dbg2(m,n) printf(" #m -- > %d #n --> %d\n",m,n)
#define pi(n) printf("%d",n)
#define pll(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(s) scanf("%s",s)
#define ps(s) printf("%s",s)
#define INF 100000009
typedef long long LL;

int palindrome(int n)
{
    int x=n/10+(n%10)*10;
    return x;
}

int main()
{
    int a,b,fg=1,pal;
    scanf("%d:%d",&a,&b);
    while(fg)
    {
	pal=palindrome(a);
	if(a>=6&&a<=9)
	{
	    printf("10:01\n");
	    break;
	}
	else if(a>=16&&a<=19)
	{
	    printf("20:02\n");
	    break;
	}
	if(pal>b)
	{
	    printf("%02d:%02d\n",a,pal);
	    break;
	}
	b=-INF;
	a=a+1;
	if(a==24)
	{
	    printf("00:00\n");
	    fg=0;
	}
	}
    return 0;
}

#include<stdio.h>

int main(void){
    char hora[5];
    scanf("%s",hora);
    int hora_num = (hora[0]-48)*10 + (hora[1]-48);
    int min_num = (hora[3]-48)*10 + (hora[4]-48);

    int hora_inver = (hora[1]-48)*10 + (hora[0]-48);
    if(hora[1] < 53){
        if(hora_inver <= min_num){
            if(hora_num < 23){
                hora_num++;
            }
            else{
                hora_num = 0;
           }
        }
    }else if(hora[1] > 53){
    	hora_num++;
    	if(hora_num%10 >= 6 && hora_num%10 <= 9){
    		hora_num = hora_num + 10 - (hora_num%10);
		}
	}else{
		if(hora_inver <= min_num){
			hora_num = hora_num + 10 - (hora_num%10);
		}
	}
    printf("%c%c:%c%c",hora_num/10+48,hora_num%10+48,hora_num%10+48,hora_num/10+48);
    return 0;
}

#include <stdio.h>

int main()
{
    int hh, mm;
    scanf("%d:%d", &hh, &mm);
    do
    {
        ++mm;
        if (mm == 60)
        {
            ++hh;
            mm = 0;
        }
        if (hh == 24)
        {
            hh = 0;
        }
    } while (hh % 10 * 10 + hh / 10 != mm);
    printf("%02d:%02d\n", hh, mm);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char hora[6],h[3],m[3];
    int palin,HoraD[5],sig,sumah,sumam,auxpalin;

    gets(hora);

    //scanf("%[^\n]s",&hora);
    //printf("%s",hora);
    h[0] = hora[0];
    h[1] = hora[1];
    m[0] = hora[3];
    m[1] = hora[4];

    //printf("%c",AuxDCambio);
    HoraD[2]=atoi(m)/10;//convierte a int
    HoraD[3]=atoi(m)%10;
    HoraD[0]= atoi(h)/10;
    HoraD[1]= atoi(h)%10;

    sumah=HoraD[0]*10 + HoraD[1];
    sumam=HoraD[2]*10 + HoraD[3];
    auxpalin=HoraD[1]*10 + HoraD[0];
    //printf("%d : %d\n%d\n",sumah,sumam,auxpalin);
    if(sumah<=sumam)
    {
        if(sumam>auxpalin)
        {
            sig=1;
            palin=0;
        }
        else if(sumam==auxpalin)
        {
            sig=1;
            palin=0;
        }
        else if(sumam<auxpalin)
        {
            sig=0;
            palin=0;
        }
    }
    //else if(sumah==sumam)
    //{
   //     palin=1;
   //     sig=1;
   // }
    else if(sumah>sumam)
    {
            sig=0;
            palin=0;

    }

    if(sumah==23 )
    {
        if(sig==1)
        {
            printf("00:00");
            exit(0);
        }
        else if(sig==0)
        {
            printf("23:32");
            exit(0);
        }
    }
    else if(HoraD[1]>5 )
    {
        if(HoraD[0]==0)
        {
        printf("10:01");
        exit(0);
        }
        else
        {
        printf("20:02");
        exit(0);
        }
    }
    else if (HoraD[1]<5)
    {
        //if(sum)
        //{
            if(sig==1 || palin==1)
            {
                printf("%d%d:%d%d",HoraD[0],HoraD[1]+1,HoraD[1]+1,HoraD[0]);
                exit(0);
            }
            else if(sig==0)
            {
                printf("%d%d:%d%d",HoraD[0],HoraD[1],HoraD[1],HoraD[0]);
                exit(0);
            }
        //}
    }
    else if (HoraD[1]==5)
    {
        if(HoraD[0]==0)
        {
            if(sig==1)
            {
            printf("10:01");
            exit(0);
            }
            else
            {
                printf("05:50");
                exit(0);
            }
        }
        else if(HoraD[0]==1)
        {
            if(sig==1)
            {
                printf("20:02");
                exit(0);
            }
            else
            {
                printf("05:50");
                exit(0);
            }
        }
    }

    return 0;
}

#include <stdio.h>
int main()
{
    int ban=1;
    int hh, mm;
scanf("%d:%d",&hh,&mm);

do
{

//COMIENZA  A SUMAR PARA AVANZAR EN EL TIEMPO
    mm++;
    if(mm==60)
    {
    hh++;
    mm=00;

    }
    if(hh==24)
    {
    hh=0;
    }

}while((hh/10!=mm%10)||(hh%10!=mm/10));
    if(mm<=9 && hh<=9)
    {
        printf("0%d:0%d",hh,mm);
    }else if(mm<=9 && hh>9)
    {
        printf("%d:0%d",hh,mm);
    }else if(mm>9 && hh<=9)
    {
        printf("0%d:%d",hh,mm);
    }
    else
    {
        printf("%d:%d",hh,mm);
    }

}

 #include<stdio.h>
 int soat,min;
 void inc(){
    min++;
    if(min==60){
        min=0;
        soat++;
        if(soat==24)soat=0;
    }
 }
 int main()
 {
     soat=getchar()-48;soat=soat*10+getchar()-48;
     getchar();
     min=getchar()-48;min=min*10+getchar()-48;
     inc();
     while((soat%10)*10+soat/10!=min)inc();
     printf("%02d:%02d",soat,min);
     return 0;
 }

#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<ctype.h>

#define MAX( a, b ) ( ( a > b) ? a : b )
#define MIN( a, b ) ( ( a < b) ? a : b )
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
#define and &&
#define or ||
int main () {

int x=0,n=0,s=0,i,j,a[10];
char b;
scanf("%d",&x);
scanf("%c",&b);
scanf("%d",&s);
n+=((x%10)*10)+x/10;
if(x>5 and x<10){
    printf("10:01");
    return 0;
}
if(s<n and n<60){
    if(x<10)
    printf("0%d:",x);
    else
    printf("%d:",x);
    if(n<10)
    printf("0%d",n);
    else
    printf("%d",n);
  return 0;}
if(x<23 and n+10<60){
    if(x<10)
    printf("0%d:%d",x+1,n+10);
    else
    printf("%d:%d",x+1,n+10);
  return 0;}
if(n+10>=60){
  printf("20:02");
  return 0;}
printf("00:00");

  return 0;
}

#include <stdio.h>

int panli(int a, int b)
{
	if ( a /10 == b%10 && a%10 == b/10)
	{
		return 0;
	}
	return 1;

}

int main(void) {
	// just check the hours
	int a,b;
	scanf("%d:%d", &a,&b);
	do
	{
		 b = (b+1) % 60;
		 if (b == 0)
		 {
		 	a = (a +1) % 24;
		 }
	}
	while (panli(a,b) != 0);
	if (a < 10)
	{
		printf("0%d", a);
	}
	else
	{
		printf("%d", a);
	}
	printf(":");
	if( b <9)
	{
		printf("0%d", b);
	}
	else
	{
		printf("%d", b);
	}

}

#include <stdio.h>
#include <stdlib.h>

void imprimirhora(int hora);
int main()
{
    int hora,minutos,h4=0;
    int I;
    int pal[]={0,110,220,330,440,550,1001,1111,1221,1331,1441,1551,2002,2112,2222,2332};

    scanf("%d:%d",&hora,&minutos);

    h4=(hora*100)+minutos;
    //printf("\n%d\n",h4);

    for(I=0;I<=15;I++)
    {
        if(pal[I]==h4&& !2332)
        {
            imprimirhora(pal[I+1]);
            break;
        }
        else if(h4<=59)
        {
            printf("01:10");
            break;
        }
        else if(pal[I]>h4)
        {
            imprimirhora(pal[I]);
            break;
        }
    }
    if(h4>=2332)
    {
        printf("00:00");
    }

    return 0;
}

void imprimirhora(int hora)
{
    int prh=0,prm=0;

        prh=hora/100;
        if (prh<10)
        {
            printf("0");
        }
        printf("%d",prh);

        prm=hora-(prh*100);
        if (prm<10)
        {
            printf(":0");
            printf("%d",prm);
        }
        else
        {
            printf(":%d",prm);
        }

}

#include <stdio.h>

#define sf scanf
#define sfi1(a) scanf("%d", &a)
#define sfi2(a,b) scanf("%d %d", &a, &b)
#define sfi3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sfi4(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define sfll1(a) scanf("%lld", &a)
#define sfll2(a,b) scanf("%lld %lld", &a, &b)
#define sfll3(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define sfll4(a,b,c,d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sfc1(a) scanf("%c", &a)
#define sfc2(a,b) scanf("%c %c", &a, &b)
#define sfc3(a,b,c) scanf("%c %c %c", &a, &b, &c)
#define sfc4(a,b,c,d) scanf("%c %c %c %c", &a, &b, &c, &d)
#define sfd1(a) scanf("%lf", &a)
#define sfd2(a,b) scanf("%lf %lf", &a, &b)
#define sfd3(a,b,c) scanf("%lf %lf %lf", &a, &b, &c)
#define sfd4(a,b,c,d) scanf("%lf %lf %lf %lf", &a, &b, &c, &d)
#define pf printf
#define loop(i,n) for(int i=0; i<n; i++)
#define rloop(i,n) for(int i=n-1; i>=0; i--)

#define INF 100000000000ll
#define MOD 1000000007ll
#define test(d) cout << "test " << d << endl;
#define start(a,b) cout <<"---------start-----" << a << " " << b << "-----------\n";
#define testReturn(i,v) cout <<"return frm " << i << " : " << v << endl;
#define testFound(i,v) cout <<"found value " << i << " : " << v << endl;
#define testBaseRet(i,v) cout <<"return frm base condition " << i << " : " << v << endl;
#define MAXN 24

//variable
int t, h, m, r_h;

//method
int rev(int x){
    return ((x%10)*10 + x/10 );
}

void Print(){
    if(h<=9) pf("0%d:", h);
    else pf("%d:", h);
    if(r_h<=9) pf("0%d\n", r_h);
    else pf("%d\n", r_h);
}

int main(){

        scanf("%d:%d", &h, &m);
        r_h = rev(h);
        while(1){
            if(r_h > m ) {
                if(r_h <= 59) {Print(); break;}
                else{
                    h = ( (int) (h/10.0 + .5) ) * 10;
                    r_h = rev(h);
                    m = -1; continue;
                }
            } else{
                h = (h+1)% 24;
                r_h = rev(h);
                m = -1;
            }
        }

    //while(1);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char tiempo[6];
    char hora[3],minuto[3],hc[3],haux[2];
    int aux;
    scanf("%s",tiempo);

    hora[0]=tiempo[0];
    hora[1]=tiempo[1];
    hora[2]='\0';

    minuto[0]=tiempo[3];
    minuto[1]=tiempo[4];
    minuto[2]='\0';

    haux[1]='\0';

    hc[1]=tiempo[0];
    hc[0]=tiempo[1];
    hc[2]='\0';

    if(atoi(hora)<10)
    {
        if(atoi(hora)<6)
        {
            if(atoi(hc) > atoi(minuto))
            {
                strcpy(minuto,hc);
            }
            else
            {
                aux = atoi(hora)+1;
                itoa(aux,haux,10);
                hora[1] = haux[0];
                minuto[0]=hora[1];
                minuto[1]=hora[0];
            }
        }
        else
        {
            strcpy(hora,"10");
            strcpy(minuto,"01");
        }
    }
    else if(atoi(hora)==15 && atoi(minuto)>=51)
    {
        strcpy(hora,"20");
        strcpy(minuto,"02");
    }
    else if(atoi(hora)>15 && atoi(hora)<20)
    {
        strcpy(hora,"20");
        strcpy(minuto,"02");
    }
    else if(atoi(hc) > atoi(minuto))
    {
        strcpy(minuto,hc);
    }
    else if(atoi(hora) == 23)
    {
        strcpy(hora,"00");
        strcpy(minuto,"00");
    }
    else
    {
        aux = atoi(hora)+1;
        itoa(aux,hora,10);
        minuto[0]=hora[1];
        minuto[1]=hora[0];
    }
    printf("%s:",hora);
    printf("%s",minuto);
    return 0;
}

#include <stdio.h>

int isPalindrome(int h, int m){

	if(h/10 == m%10 && h%10 == m/10)	return 1;
	return 0;

}

void printOut(int h, int m){
	if(h/10==0 && m/10==0)	printf("0%d:0%d\n",h,m);
	else if(h/10==0)	printf("0%d:%d\n",h,m);
	else if(m/10==0)	printf("%d:0%d\n",h,m);
	else printf("%d:%d\n",h,m);
}

int main(void){

	int h,m;
	int isFound=0;

	scanf("%d:%d",&h,&m);

	for(m=m+1 ; m<60 && !isFound; m++){
		if(isPalindrome(h,m)){
			printOut(h,m);
			isFound=1;
		}
	}

	for(h=h+1 ; h<24 ; h++){
		for(m=0 ; m<60 && !isFound; m++){
			if(isPalindrome(h,m)){
				printOut(h,m);
				isFound=1;
			}
		}
	}

	for(h=0 ; h<24 ; h ++){
		for(m=0 ; m<60 && !isFound ; m++){
			if(isPalindrome(h,m)){
				printOut(h,m);
				isFound=1;
			}
		}
	}

	return 0;
}
/****** PCCA -Mon Oct 03 11:57:58 GMT 2011 *******/

#include<stdio.h>
int telll(int);
int printit(int);
int palindrome(int a,int b);
int main()
{
    char c[6];
    scanf("%s",c);
    int a=0,b=0,d=0;
    a=c[1]-'0';
    b=c[0]-'0';
    a=(b*10)+a;
    b=c[3]-'0';
    d=c[4]-'0';
    b=(b*10)+d;
    int e;
    d=a;
    e=b;
    int t=0;
    if(palindrome(d,e))
    {
        e++;
    }
    do
    {
        int k=telll(d);

        if(e<=k)
        {
            if(k>59)
            {
                d++;
            }
            else
            {
                printit(d);
                printf(":");
                printit(k);
                return 0;
            }
        }
        else if(e>k)
        {
            d++;
        }
        if(d>23)
        {
            d=00;
        }
        e=00;
    }while(!palindrome(d,e));
                printit(d);
                printf(":");
                printit(e);
    return 0;

}
int telll(int j)
{
    int l;
    l=j%10;
    j=j/10;
    l=(l*10)+j;
    return l;
}
int palindrome(int a,int b)
{
    int c,d;
    c=a%10;
    a=a/10;
    d=b%10;
    b=b/10;
    if((c==b)&&(a==d))
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
int printit(int a)
{
    if(a<10)
    {
        switch(a)
        {
            case 1 :printf("01");
                    break;
            case 2 :printf("02");
                    break;
            case 3 :printf("03");
                    break;
            case 4 :printf("04");
                    break;
            case 5 :printf("05");
                    break;
            case 6 :printf("06");
                    break;
            case 7 :printf("07");
                    break;
            case 8 :printf("08");
                    break;
            case 9 :printf("09");
                    break;
            case 0 :printf("00");
                    break;
        }
    }
    else
    {
        printf("%d",a);
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define TAM 3

int inversa(int n){
    int inv, cociente, resto;
    cociente= n/10;
    resto= n%10;
    inv = (resto*10)+cociente;
    return inv;
}

void imprimeHora(int hs, int ms){
    if(hs<10&& ms>=10) printf("0%d:%d", hs, ms);
    else if(hs>=10 && ms<10)  printf("%d:0%d", hs, ms);
    else if(hs<10 && ms<10)  printf("0%d:0%d", hs, ms);
    else if(hs>=10&& ms>=10)printf("%d:%d", hs, ms);
}

int Busca(int numero, int a[]){
    int i;
    for(i=0; i<24; i++){
        if(numero == a[i]) return i;
    }
}

int main(){

    char* h;
    char He[TAM];
    char Me[TAM];
    int he, me, hs, ms, exito, pos, H, M;
    char cadena[6];
    int Hora[24]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,00};
    int InvHora[24]={10,20,30,40,50,60,70,80,90,01,11,21,31,41,51,61,71,81,91,02,12,22,32,00};
    int validaHora[24]={1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1};

    scanf("%s", cadena);

    h = strtok(cadena, ":");
    He[0]= *(h);
    He[1]=*(h+1);
    He[2]= '\0';

    h= strtok(NULL, ":");
    Me[0]= *(h);
    Me[1]= *(h+1);
    Me[2]= '\0';

    he= H= atoi(He);
    me =M= atoi(Me);
    //printf("\nPRUEBA  %d:%d\n", he, me);

    if(me== inversa(he)){
            if(he==23){
                hs=00;
                ms=00;
            }else{
                hs= he+1;
                ms=me+10;
                pos = Busca(ms, InvHora);
                    if(validaHora[pos]==0){
                        while(exito!=1){
                            ++pos;
                            ++he;
                            if(validaHora[pos]!=0){
                                ms= InvHora[pos];
                                hs=Hora[pos];
                                exito=1;
                            }else{
                                exito=0;
                            }
                        }
                    }
            }

            imprimeHora(hs,ms);

    }else if(me < inversa(he)){
            exito=0;
            pos= Busca(he, Hora);
            //printf("\nPrueba : %d\n", pos);

            if(validaHora[pos]!= 0){
                ms= InvHora[pos];
                hs= Hora[pos];
            }else{
                while(exito!= 1){
                    ++pos;
                    ++he;
                    //printf("\nPrueba : %d\n", pos);
                    if(validaHora[pos]!= 0){
                        ms=InvHora[pos];
                        hs=Hora[pos];
                        exito=1;
                        //printf("\nPrueba : %d:%d\n", hs,ms);
                    }else{
                        exito=0;
                    }
                }
            }

            imprimeHora(hs,ms);

        }else if(me> inversa(he)){
            if(he==23){
                hs=00;
                ms=00;

            }else if(he==00){
                hs=01;
                ms=10;

            }else{
                pos = Busca(he, Hora);
                exito=0;

                while(exito!= 1){
                    ++pos;  ++he;
                    if(validaHora[pos] != 0){
                        ms=InvHora[pos];
                        hs=Hora[pos];
                        exito=1;
                    }else{
                        exito=0;
                    }
                }

            }
            imprimeHora(hs,ms);
        }

printf("\n");

    return 0;
}

#include <stdio.h>

int SigH(int h)
{
    if(h==23)
    {
        return 0;
    }
    return h+1;
}

int main()
{
    int H,M,temp;
    scanf("%d:%d",&H,&M);
    temp=(H%10)*10+H/10;
    if(temp>M&&temp>=0&&temp<60)
    {
        printf("%02d:%02d\n",H,temp);
        return 0;
    }
    while(1)
    {
        H=SigH(H);
        M=(H%10)*10+H/10;
        if(M>=0&&M<60)
        {
            printf("%02d:%02d\n",H,M);
            break;
        }
    }
    return 0;
}

//Palindromic Times

# include <stdio.h>

int main()
{
    char tiempo[6];
    char hora[3];
    char minuto [3];
    char horai[3];
    int h, m, hi;

    scanf("%s", tiempo);

    hora[0] = horai[1] = tiempo[0];
    hora[1] = horai[0] = tiempo[1];
    hora[2] = horai[2] = '\0';

    minuto[0] = tiempo [3];
    minuto[1] = tiempo [4];
    minuto[2] = '\0';

    h = atoi(hora);
    m = atoi(minuto);
    hi = atoi(horai);

    if(hi > m && hi < 60)
    {
        tiempo[3] = tiempo[1];
        tiempo[4] = tiempo[0];
        printf("%s", tiempo);
    }
    else
    {
        h++;
        while( (h > 05 && h < 10) || (h > 15 && h < 20) )
            h++;

        if(h == 24)
            h = 00;

        sprintf(hora,"%02d",h);
        printf ("%s:%c%c", hora, hora[1], hora[0]);
    }
    return 0;
}

#include <stdio.h>

 main()
{
    int hh=0, mm=1;

    while (  ((hh%10)*10) + (hh/10) != mm ) /*se da la vuelta la hora si son iguales se encontro*/
    {
        scanf("%d:%d" ,&hh,&mm);
        mm++;

        if (mm == 60)
        {
            mm=0;
            hh++;
        }

        if (hh == 24)
        {
            hh=0;

        }

    }
        printf("%02d:%02d\n", hh, mm);
        return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char enteroACaracter(int numero);

int main() {
    char cad[6];
    scanf("%s", cad);
    char HH[3], MM[3], auxH[3];
    HH[0] = '\0';
    MM[0] = '\0';
    int i;

    HH[0] = cad[0];
    HH[1] = cad[1];

    MM[0] = cad[3];
    MM[1] = cad[4];

    int hh, mm, auxh;
    hh = atoi(HH);
    mm = atoi(MM);

    auxH[0] = HH[1];
    auxH[1] = HH[0];

    auxh = 0;
    for (i = 0; i < 2; i++) {
        auxh = auxh + (auxH[i] - 48);
        if (i == 0) {
            auxh *= 10;
        }

    }

    if (auxh <= mm || auxh > 59) {
        if (hh == 23) {
            hh = 0;
            mm = 0;
        } else {
            hh++;
            auxH[0] = enteroACaracter(hh / 10);
            auxH[1] = enteroACaracter(hh % 10);

            HH[0] = auxH[1];
            HH[1] = auxH[0];

            mm = atoi(HH);
            while (mm > 59) {
                hh++;
                auxH[0] = enteroACaracter(hh / 10);
                auxH[1] = enteroACaracter(hh % 10);

                HH[0] = auxH[1];
                HH[1] = auxH[0];

                mm = atoi(HH);
            }
        }

    } else {
        mm = auxh;
    }
    if(hh<10 && mm<10){
        printf("0%d:0%d", hh, mm);
    }else if(mm<10){
        printf("%d:0%d", hh, mm);
    }else if(hh<10){
        printf("0%d:%d", hh, mm);
    }else{
        printf("%d:%d", hh, mm);
    }

    return (EXIT_SUCCESS);
}

char enteroACaracter(int numero) {
    return numero + '0';
}

#include <stdio.h>
#include <string.h>

int main(){
	char s[6];
	scanf("%s",s);

	//HH:MM
	char hora[3]; 	//HH
	char minu[3];	//MM
	hora[0] = s[0];
	hora[1] = s[1];

	minu[0] = s[3];
	minu[1] = s[4];

	minu[2] = hora[2] = '\0';

	//printf("%s %s %s\n",s,hora,minu);
	//12:21
	//13:31

	int i; //las horas y minutos en los minutos
	for (i = (60*atoi(hora)+atoi(minu)+1); i < 1440; i++)
	{
		//printf("%d---%02d %02d\n",i,i/60,i%60);
		if(isPalin(i/60, i%60)){
			break;
		}
	}
	if(i!=1440)
		printf("%02d:%02d\n",i/60,i%60);
	else
		printf("00:00");

	return 0;
}

int isPalin(int x, int y){

	char hh[3];
	sprintf(hh,"%02d",x);

	char mm[3];
	sprintf(mm,"%02d",y);

	if(hh[0]==mm[1] && hh[1]==mm[0])
		return 1;
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int reverse(int a){
	int one,ten;
	one=a%10;
	ten=a/10;
	return one*10+ten;
}

int main(void)
{
	int hh,mm,h,hd,i,j;
	char syn[6];

	scanf("%s",syn);
	syn[2]='\0';
	hh=atoi(syn);
	mm=atoi(&syn[3]);
	//for(i=0;i<24;i++){
	//	for(j=0;j<60;j++){
	//		hh=i;
	//		mm=j;
			h=hh%10;
			hd=hh/10;
			if(h<5){
				if(mm>=reverse(hh))printf("%02d:%02d\n",(hh+1)%24,reverse((hh+1)%24));
				else printf("%02d:%02d\n",(hh)%24,reverse((hh)%24));
			}
			else if(h==5){
				if(mm>=reverse(hh))printf("%d0:0%d\n",hd+1,hd+1);
				else printf("%02d:%02d\n",(hh)%24,reverse((hh)%24));
			}
			else{
				printf("%d0:0%d\n",hd+1,hd+1);
	//		}
	//	}
	}
	return 0;
}

#include <stdio.h>
int main()
{
    char c[10];
    scanf("%s", c);
    int num1=10*(c[0]-'0')+(c[1]-'0');
    int num2=10*(c[3]-'0')+(c[4]-'0');
    //printf("%d %d", num1, num2);
    int ttemp=num1;
    int pnum1=0;
    while(ttemp)
    {
        int temp=ttemp%10;
        pnum1*=10;
        pnum1+=temp;
        ttemp/=10;
    }
    if(num1/10==0)
        pnum1*=10;
    //printf(" %d\n", pnum1);
    if(num2<pnum1 && pnum1<60)
    {
        if(num1/10==0)
                {
                    if(pnum1/10==0)
                    {
                        printf("0%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("0%d:%d\n", num1, pnum1);
                }
                else
                {
                    if(pnum1/10==0)
                    {
                        printf("%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("%d:%d\n", num1, pnum1);
                }
    }
        //printf("%d:%d\n", num1, pnum1);
    else
    {
        while(1)
        {
            num1+=1;
            num1%=24;
            ttemp=num1;
            pnum1=0;
            while(ttemp)
            {
                int temp=ttemp%10;
                pnum1*=10;
                pnum1+=temp;
                ttemp/=10;
            }
            if(num1/10==0)
                pnum1*=10;
            //printf("num1=%d pnum1=%d\n", num1, pnum1);
            if(pnum1<=60)
            {
                if(num1/10==0)
                {
                    if(pnum1/10==0)
                    {
                        printf("0%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("0%d:%d\n", num1, pnum1);
                }
                else
                {
                    if(pnum1/10==0)
                    {
                        printf("%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("%d:%d\n", num1, pnum1);
                }
                break;
            }
        }
    }
}

#include <stdio.h>
#include <math.h>

int main(void){
    int minuto=0,hora=0;
    char txt[5]={'0','0','0','0','0'}; //Inicializacion de la cadena que guarda el modelo HH:MM
    scanf("%s",&txt);//Carga de la hora en formato HH:MM
    getchar();
    fflush (stdin);
    hora=(txt[0]-'0')*10; //En la variable 'hora' se carga la decena de la hora introducida
    hora=hora+txt[1]-'0'; //Se carga la unidad de la hora en la variable 'hora' y se le suma a la decena extraida en la linea 10
    minuto=(txt[3]-'0')*10; //En la variable 'minuto' se carga la decena del minuto introducido
    minuto=minuto+txt[4]-'0'; //Se carga la unidad del minuto en la variable 'minuto' y se le suma a la decena extraida en la linea 12
    minuto++; //Aumentamos el minuto en uno por si se introdujo un hora capicua
   while(minuto>0)
    {
        if(minuto==60)//Si el minuto es 60 entonces agregamos sumamos 1 a hora y minuto vuelve a 0
        {
            minuto=0;
            hora++;
            if(hora==24) //Si hora es 24 se reinicia el reloj a la hora 00
            {
                hora=0;
            }
        }
        txt[0]=floor(hora/10)+'0'; //Se vuelve cada digito nuevamente a su posicion correspondiente en el array de char
        txt[1]=hora%10+'0';
        txt[3]=floor(minuto/10)+'0';
        txt[4]=minuto%10+'0';
        if(txt[0]==txt[4] && txt[1]==txt[3]) //Cuando se cumple la condicion de capicua se imprime y rompe el ciclo
        {
            printf("%s",txt);
            break;
        }
        minuto++; //Contador de minuto para buscar la siguiente hora capicua
    }
}

#include <stdio.h>

int reverse(int a) {

	return (a % 10) * 10 + ((a / 10) % 10);

}

int main() {
	int h, m;

	while (scanf("%d:%d", &h, &m) != EOF)
	{
		if (h == reverse(m) || reverse(h) < m)
			h++;

		if (h > 5 && h < 10) //6 ao 9, 16 ao 19
			h = 10;
		else
			if (h > 15 && h < 20)
				h = 20;

		if (h > 23)
			h = 0;

		m = reverse(h);

		printf("%.2d:%.2d\n", h, m);
	}

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char enteroACaracter(int numero);

int main() {
    char cad[6];
    scanf("%s", cad);
    int hh, mm, auxh,i;
    char HH[3], MM[3], auxH[3];

    HH[0] = cad[0];
    HH[1] = cad[1];

    MM[0] = cad[3];
    MM[1] = cad[4];

    hh = atoi(HH);
    mm = atoi(MM);

    auxH[0] = HH[1];
    auxH[1] = HH[0];

    auxh = 0;
    auxh=atoi(auxH);

    if (auxh <= mm || auxh > 59) {
        if (hh == 23) {
            hh = 0;
            mm = 0;
        } else {
            hh++;
            auxH[0] = enteroACaracter(hh / 10);
            auxH[1] = enteroACaracter(hh % 10);

            HH[0] = auxH[1];
            HH[1] = auxH[0];

            mm = atoi(HH);
            while (mm > 59) {
                hh++;
                auxH[0] = enteroACaracter(hh / 10);
                auxH[1] = enteroACaracter(hh % 10);

                HH[0] = auxH[1];
                HH[1] = auxH[0];

                mm = atoi(HH);
            }
        }

    } else {
        mm = auxh;
    }
    if(hh<10 && mm<10){
        printf("0%d:0%d", hh, mm);
    }else if(mm<10){
        printf("%d:0%d", hh, mm);
    }else if(hh<10){
        printf("0%d:%d", hh, mm);
    }else{
        printf("%d:%d", hh, mm);
    }

    return (EXIT_SUCCESS);
}

char enteroACaracter(int numero) {
    return numero + '0';
}

#include <stdio.h>

int reverse(int b) {

	return (b % 10) * 10 + ((b / 10) % 10);

}

int main() {
	int h, m;

	while (scanf("%d:%d", &h, &m) != EOF)
	{
		if (h == reverse(m) || reverse(h) < m)
			h++;

		if (h > 5 && h < 10) //6 ao 9, 16 ao 19
			h = 10;
		else
			if (h > 15 && h < 20)
				h = 20;

		if (h > 23)
			h = 0;

		m = reverse(h);

		printf("%.2d:%.2d\n", h, m);
	}

	return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int h1, h2, m1, m2, hora, minuto, m_invertido;
    h1 = getchar() - '0';
    h2 = getchar() - '0';
    hora = h1 * 10 + h2;
    getchar();
    m1 = getchar() - '0';
    m2 = getchar() - '0';
    minuto = m1 * 10 + m2;

    while(1)
    {
        minuto++;
        if(minuto == 60)
        {
            minuto = 0;
            hora++;
            if(hora == 24) hora = 0;
        }
        if(hora / 10 == minuto % 10 && hora %10 == minuto / 10)
        {
            printf("%02d:%02d", hora, minuto);
            return 0;
        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int hora,Min;
    int Aux,i;
    float H;

    scanf("%d:%d",&hora,&Min);

    //Calcula la siguiente hora inmediata//
    if(Min<59)
        Min++;
    else{
        Min=0;
        hora++;
    }
    while(hora!=24){
        Aux=hora/10;
        H=(((float)hora/10)-Aux)*100+Aux;
        for (i=Min;Min<=59;Min++){
            if(H==Min){
                if(hora<10){
                    printf("0%d:",hora);
                }
                else{
                    printf ("%d:",hora);
                }
                if(Min<10){
                    printf("0%d",Min);
                }
                else{
                    printf ("%d",Min);
                }
                break;
            }
        }
        if(H==Min)
            break;
        hora++;
        Min=1;
    }
    if(hora==24)
        printf("00:00");

    return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int hora,Min;
    int Aux,i;
    float H;

    scanf("%d:%d",&hora,&Min);

    //Calcula la siguiente hora inmediata//
    if(Min<59)
        Min++;
    else{
        Min=0;
        hora++;
    }
    while(hora!=24){
        Aux=hora/10;
        H=(((float)hora/10)-Aux)*100+Aux;
        for (i=Min;Min<=59;Min++){
            if(H==Min){
                if(hora<10){
                    printf("0%d:",hora);
                }
                else{
                    printf ("%d:",hora);
                }
                if(Min<10){
                    printf("0%d",Min);
                }
                else{
                    printf ("%d",Min);
                }
                break;
            }
        }
        if(H==Min)
            break;
        hora++;
        Min=1;
    }
    //Caso especial cuando la hora inicial es 23:59//
    if(hora==24)
        printf("00:00");

    return 0;

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int inv(int a);

int main()
{
	char cad[5]={""}, hora[3], min[3];
	scanf("%s", cad);
	strncpy(hora, cad, 2);
	strncpy(min, &cad[3], 2);
	int h=atoi(hora), m=atoi(min);				//h va ser la hora de la cadena y m el minuto
	int exito=0;
	if (m>=inv(h) || (h>5 && h<10) || (h>15 && h<20))
	{
		h++;
		if (h>5 && h<10)						//los intervalos en que no puede ser capicua
		{
			printf("10:01\n");
			exito=1;
		}
		else if (h>15 && h<20)
		{
			printf("20:02\n");
			exito=1;
		}
		else if (h==24)							//caso sencillo 24=00
		{
			printf("00:00\n");
			exito=1;
		}
		if (exito==0)							//si no entro en uno de los casos sencillos
		{
			if (h<10)
				printf("0");
			printf("%d:", h);
			if (inv(h)<10)
				printf("0");
			printf("%d\n", inv(h));
		}
	}
	else
	{
		if (h<10)
			printf("0");
		printf("%d:", h);
		if (inv(h)<10)
			printf("0");
		printf("%d\n", inv(h));
	}
	return 0;
}

int inv(int a)
{	//retorna el inverso de un numero de 2 digitos
	return a/10+(a%10)*10;
}

#include <stdio.h>
#include <stdlib.h>

int chequearIgualdad(int hora, int min);

int main(){
    char tiempo[5];

    int hora = 0,min = 0;
    int * h = &hora;
    int * m = &min;

    fflush(stdin);
    scanf("%s", tiempo);

    hora = (tiempo[0] - '0') * 10 + (tiempo[1] - '0');
    min = (tiempo[3] - '0') * 10 + (tiempo[4] - '0');

    if(!chequearIgualdad(hora,min)){
        if(min == 59){
            min = 0;
            if(hora == 23){
                hora = 0;
            }else{
                hora++;
            }
        }else{
            min++;
        }
    }

    while (chequearIgualdad(hora,min)){
        if(min == 59){
            min = 0;
            if(hora == 23){
                hora = 0;
            }else{
                hora++;
            }
        }else{
            min++;
        }
    }

    if(hora<10 && min<10){
        printf("0%d:0%d",hora,min);
    }else if(hora<10){
        printf("0%d:%d",hora,min);
    }else if(min<10){
        printf("%d:0%d",hora,min);
    }else{
        printf("%d:%d",hora,min);
    }

    return 0;
}

int chequearIgualdad(int hora, int min){
    int dec,un;

    un = min%10;
    dec = min/10;

    min = un*10 + dec;

    if(hora == min){
        return 0;
    }else{
        return 1;
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sigPalindromo(char [], char [], int, int);
int inv (int n);
void aumentar(char [], int *);
int palindromo(char [], char []);

main()
{
    char clock[5];
    char hora[3];
    char min[3];

    int vhora, vmin;

    scanf("%d:%d", &vhora, &vmin);

    printf("%d:%d", vhora, vmin);

    hora[0]=(vhora/10)+'0';
    hora[1]=(vhora%10)+'0';
    hora[2]='\0';

    printf("\nhora: %s", hora);

    min[0]=(vmin/10)+'0';
    min[1]=(vmin%10)+'0';
    min[3]='\0';

    printf("\nmin: %s", min);

    sigPalindromo(hora, min, vhora, vmin);

/*  printf("\n");
    system("pause");*/

    return 0;
}
int palindromo(char hora[], char min[])
{
    if(hora[0]==min[1] && hora[1]==min[0])
        return 1;
    else
        return 0;
}

void sigPalindromo(char hora[], char min[], int vhora, int vmin)
{
        if(vhora>15 && vhora<20)
        {
            printf("\n20:02");
        }
        else if(vhora>5 && vhora<10)
        {
            printf("\n10:01");
        }
        else if(vmin < inv(vhora))
        {
            /*printf("\nel inverso de %d es %d\n", vhora, inv(vhora));*/

            itoa(vhora, hora, 10);
            if(vhora<10)
            {
                hora[1]=hora[0];
                hora[0]='0';
                hora[3]='\0';
            }
            printf("\n%s:%c%c", hora, hora[1], hora[0]);
        }
        else if(vhora<23)
        {
        /*  printf("\nvhora == %d", vhora);*/
            aumentar(hora, &vhora);
            sigPalindromo(hora, "00", vhora, 0);
        }
        else
        {
            printf("\n00:00");
        }
}

int inv (int n)
{
    int d1, d2;

    d1 = n%10;
    d2 = n/10;

    return (d1*10)+d2;
}

void aumentar(char hora[], int *vhora)
{
    if(*vhora < 23)
    {
        *vhora= (*vhora)+1;
        hora[1] = hora[1]+1;
    }
    else
    {
        *vhora=0;
        hora[0]=0;
        hora[1]=0;
    }

}

#include <stdio.h>
#include <stdlib.h>

main(){
struct palindromic {
                    int H;
                    int M;} PALINDROMIC[16];
int c,HH,MM;

PALINDROMIC[0].H=00;
PALINDROMIC[0].M=00;

PALINDROMIC[1].H=01;
PALINDROMIC[1].M=10;

PALINDROMIC[2].H=02;
PALINDROMIC[2].M=20;

PALINDROMIC[3].H=03;
PALINDROMIC[3].M=30;

PALINDROMIC[4].H=04;
PALINDROMIC[4].M=40;

PALINDROMIC[5].H=05;
PALINDROMIC[5].M=50;

PALINDROMIC[6].H=10;
PALINDROMIC[6].M=01;

PALINDROMIC[7].H=11;
PALINDROMIC[7].M=11;

PALINDROMIC[8].H=12;
PALINDROMIC[8].M=21;

PALINDROMIC[9].H=13;
PALINDROMIC[9].M=31;

PALINDROMIC[10].H=14;
PALINDROMIC[10].M=41;

PALINDROMIC[11].H=15;
PALINDROMIC[11].M=51;

PALINDROMIC[12].H=20;
PALINDROMIC[12].M=02;

PALINDROMIC[13].H=21;
PALINDROMIC[13].M=12;

PALINDROMIC[14].H=22;
PALINDROMIC[14].M=22;

PALINDROMIC[15].H=23;
PALINDROMIC[15].M=32;

scanf("%d:%d",&HH , &MM);

c=0;
if(HH==23) {
    if (32<=MM){
    printf("%0.2d:%0.2d",PALINDROMIC[0].H,PALINDROMIC[0].M );
    }else{
      printf("%0.2d:%0.2d",PALINDROMIC[15].H,PALINDROMIC[15].M );}
}
else{
while(HH>=PALINDROMIC[c].H){
c++;
}
if (MM<PALINDROMIC[c-1].M){
printf("%0.2d:%0.2d",PALINDROMIC[c-1].H,PALINDROMIC[c-1].M );
}else{
printf("%0.2d:%0.2d",PALINDROMIC[c].H,PALINDROMIC[c].M );
}
}

return 0;
}

#include <stdio.h>
rev(int a){
	int b=0;
	while(a){
		b*=10;
		b+=(a%10);
		a/=10;
	}
	return b;
}
int main()
{
    int hh, mm;
    scanf("%d:%d", &hh, &mm);
    if(mm==rev(hh)){
    	mm++;
    	if(mm == 60)
        {
            hh++;
            mm = 0;
        }
	}
    while(mm!=rev(hh))
    {
        mm++;
        if (mm == 60)
        {
            hh++;
            mm = 0;
        }
        if (hh == 24)
        {
            hh = 0;
        }
    }
    printf("%02d:%02d\n", hh, mm);
    //scanf("%d" ,&hh); printf("rev of hh is: %02d" ,rev(hh));
    return 0;
}

#include <stdio.h>

int reverse(int a){
	int one,ten;
	one=a%10;
	ten=a/10;
	return one*10+ten;
}

int main(void)
{
	int hh,mm,h,hd;
	char syn[6];
	scanf("%s",syn);
	syn[2]='\0';
	hh=atoi(syn);
	mm=atoi(&syn[3]);
	h=hh%10;
	hd=hh/10;
	if(h<=5){
		if(mm>=reverse(hh))printf("%02d:%02d\n",(hh+1)%24,reverse((hh+1)%24));
		else printf("%02d:%02d\n",(hh)%24,reverse((hh)%24));
	}
	else{
		printf("%d0:0%d\n",hd+1,hd+1);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void siguiente_palindromo(char*);
int char_int(char );
int main()
{
    char  comienzo[10];
    scanf("%s",comienzo);

    siguiente_palindromo(comienzo);
    return 0;
}
void siguiente_palindromo(char *inicio){
    int hora[]={0,0};
    int minutos[]={0,0};
    int i,j, k=0;
    for(i=0; inicio[i]!=':'; i++){
        if(char_int(inicio[i])!=-1){
            hora[i]=char_int(inicio[i]);
        }
    }
    for(j=i; inicio[j]!='\0'; j++){
        if(char_int(inicio[j])!=-1){
            minutos[k]=char_int(inicio[j]);
            k++;
        }
    }

    if((minutos[0]*10+minutos[1]) > (hora[1]*10+hora[0])){
        hora[1]++;
        if(hora[1]>5){
            hora[0]++;
            hora[1]=0;
        }
        if((hora[0]*10+hora[1])==24){
            hora[0]=0;
            hora[1]=0;
        }

    }
    minutos[0]=hora[1];
    minutos[1]=hora[0];
    printf("\n%d%d:%d%d",hora[0],hora[1],minutos[0],minutos[1]);
}
int char_int(char a){
    char numeros[]={'0','1','2','3','4','5','6','7','8','9'};
    int i;
    for(i=0; i<10; i++){
        if(a==numeros[i]){
            return i;
        }
    }
    return -1;
}

//SORU xx
//PROGRAM C
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<time.h>
#include<ctype.h>
//#include<math.h>
#define scn(x) fscanf(in,"%d",&x);
#define prn(x) fprintf(out,"%d\n",x);
#define prn2(x) fprintf(out,"%d",x);
#define line() fprintf(out,"\n");
#define wait system("PAUSE");
#define scn2(x,y) scn(x);scn(y);
FILE *in,*out;
void dosya(){
		/*in=fopen("girdi.in","r");*/in=stdin;
		/*out=fopen("cikti.out","w");*/out=stdout;
}
int h,m;
void oku(){
	char c;
	scn(h);
	fscanf(in," %c",&c);
	scn(m);
}
void coz(){
	int i,j,tut1,tut2,yer=0;
	for(i=h+1; i<=23; i++){
		for(j=0; j<=60; j++){
			tut1=i;
			tut2=j;
			if((tut1-(tut1%10))/10==tut2%10 && (tut2-(tut2%10))/10==tut1%10){
				fprintf(out,"%d%d:%d%d",(tut1-(tut1%10))/10,(tut2-(tut2%10))/10,tut1%10,tut2%10);
				yer=1;
				break;
			}
		}
		if(yer) break;
	}
	if(!yer) fprintf(out,"00:00");
}
int main(){
	dosya();
	oku();
	coz();
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char hora[6],h[3],m[3];
    int palin,HoraD[5],sig,sumah,sumam,auxpalin;

    gets(hora);

    //scanf("%[^\n]s",&hora);
    //printf("%s",hora);
    h[0] = hora[0];
    h[1] = hora[1];
    m[0] = hora[3];
    m[1] = hora[4];

    //printf("%c",AuxDCambio);
    HoraD[2]=atoi(m)/10;//convierte a int
    HoraD[3]=atoi(m)%10;
    HoraD[0]= atoi(h)/10;
    HoraD[1]= atoi(h)%10;

    sumah=HoraD[0]*10 + HoraD[1];
    sumam=HoraD[2]*10 + HoraD[3];
    auxpalin=HoraD[1]*10 + HoraD[0];

    if(sumah<sumam)
    {
        if(sumam>auxpalin)
        {
            sig=1;
            palin=0;
        }
        else if(sumam==auxpalin)
        {
            sig=1;
            palin=0;
        }
        else if(sumam<auxpalin)
        {
            sig=0;
            palin=0;
        }
    }
    else if(sumah==sumam)
    {
        palin=1;
        sig=1;
    }
    else if(sumah>sumam)
    {
            sig=0;
            palin=0;

    }

    if(sumah==23 )
    {
        if(sig==1)
        {
            printf("00:00");
            exit(0);
        }
        else if(sig==0)
        {
            printf("23:32");
            exit(0);
        }
    }
    else if(HoraD[1]>5 )
    {
        if(HoraD[0]==0)
        {
        printf("10:01");
        exit(0);
        }
        else
        {
        printf("20:02");
        exit(0);
        }
    }
    else if (HoraD[1]<5)
    {
        //if(sum)
        //{
            if(sig==1 || palin==1)
            {
                printf("%d%d:%d%d",HoraD[0],HoraD[1]+1,HoraD[1]+1,HoraD[0]);
                exit(0);
            }
            else if(sig==0)
            {
                printf("%d%d:%d%d",HoraD[0],HoraD[1],HoraD[1],HoraD[0]);
                exit(0);
            }
        //}
    }
    else if (HoraD[1]==5)
    {
        if(HoraD[0]==0)
        {
            if(sig==1)
            {
            printf("10:01");
            exit(0);
            }
            else
            {
                printf("05:50");
                exit(0);
            }
        }
        else if(HoraD[0]==1)
        {
            if(sig==1)
            {
                printf("20:02");
                exit(0);
            }
            else
            {
                printf("05:50");
                exit(0);
            }
        }
    }

    return 0;
}

#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<ctype.h>

#define MAX( a, b ) ( ( a > b) ? a : b )
#define MIN( a, b ) ( ( a < b) ? a : b )
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
#define and &&
#define or ||
int main () {

int x=0,n=0,s=0,i,j,a[10];
char b;
scanf("%d",&x);
scanf("%c",&b);
scanf("%d",&s);
n+=((x%10)*10)+x/10;
if(x<10){
    printf("10:01");
    return 0;
}
if(s<n){
    if(x<10)
    printf("0%d:",x);
    else
    printf("%d:",x);
    if(n<10)
    printf("0%d",n);
    else
    printf("%d",n);
  return 0;}
if(x<23 and n+10<60){
    if(x<10)
    printf("0%d:%d",x+1,n+10);
    else
    printf("%d:%d",x+1,n+10);
  return 0;}
if(n+10>=60){
  printf("20:02");
  return 0;}
printf("00:00");

  return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int funcelias (char a);

int main()
{
	int i,j=0,k,l ;
	int aux[4];
	char hora[6];
	int flag=0 ;
	scanf("%s", hora) ;

	for(i=0;'\0'!=hora[i];i++){

		if(funcelias(hora[i])!=-1){
			aux[j]=funcelias(hora[i]);
			j++;
		}
	}
	if((aux[0]*10+aux[1])<24)
	{
		while(flag!=1){

		for(i=aux[0] ; i<3 && flag==0; i++)
		{
			for(k=aux[1] ; k<4 && flag==0; k++)
			{
				for(j=aux[2] ; j<6 && flag==0; j++)
				{
					for(l=aux[3]+1 ; l<10 && flag==0; l++)
					{
						if(i==l && k==j)
						{
							flag=1 ;
							printf("%d%d:%d%d",i,k,j,l) ;
						}
					}
					aux[3]=-1;
				}
				aux[2]=0;
			}
			aux[1]=0;

		}
		aux[0]=0;

		}
	}
	return 0 ;
}
int funcelias (char a)
{
	int i;

	char numero[]= {'0','1','2','3','4','5','6','7','8','9'}	;
	for(i=0; i<10; i++)
	{

		if(a==numero[i])
		{
			return i;
		}

	}
	return -1;
}

#include <stdio.h>
#include <stdlib.h>

main(){
struct palindromic {
                    int H;
                    int M;} PALINDROMIC[16];
int c,HH,MM;

PALINDROMIC[0].H=00;
PALINDROMIC[0].M=00;

PALINDROMIC[1].H=01;
PALINDROMIC[1].M=10;

PALINDROMIC[2].H=02;
PALINDROMIC[2].M=20;

PALINDROMIC[3].H=03;
PALINDROMIC[3].M=30;

PALINDROMIC[4].H=04;
PALINDROMIC[4].M=40;

PALINDROMIC[5].H=05;
PALINDROMIC[5].M=50;

PALINDROMIC[6].H=10;
PALINDROMIC[6].M=01;

PALINDROMIC[7].H=11;
PALINDROMIC[7].M=11;

PALINDROMIC[8].H=12;
PALINDROMIC[8].M=21;

PALINDROMIC[9].H=13;
PALINDROMIC[9].M=31;

PALINDROMIC[10].H=14;
PALINDROMIC[10].M=41;

PALINDROMIC[11].H=15;
PALINDROMIC[11].M=51;

PALINDROMIC[12].H=20;
PALINDROMIC[12].M=02;

PALINDROMIC[13].H=21;
PALINDROMIC[13].M=12;

PALINDROMIC[14].H=22;
PALINDROMIC[14].M=22;

PALINDROMIC[15].H=23;
PALINDROMIC[15].M=32;

scanf("%d:%d",&HH , &MM);
c=0;
if(HH==23) {
    if (32<=MM){
    printf("%0.2d:%0.2d",PALINDROMIC[0].H,PALINDROMIC[0].M );
    }else{
      printf("%0.2d:%0.2d",PALINDROMIC[15].H,PALINDROMIC[15].M );}
}
else{
while(HH>PALINDROMIC[c].H){
c++;
}
if (MM<PALINDROMIC[c-1].M && HH==PALINDROMIC[c-1].H){
printf("%0.2d:%0.2d",PALINDROMIC[c-1].H,PALINDROMIC[c-1].M );
}else{
printf("%0.2d:%0.2d",PALINDROMIC[c].H,PALINDROMIC[c].M );
}
}

return 0;
}

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

	char time[6];
	int heure,minute;
	scanf("%s",&time);
	heure=((time[0]-48)*10)+time[1]-48;
	minute=((time[3]-48)*10)+time[4]-48;

	if(heure<1 || heure==1&&minute<=10){printf("01:10");return 0;}
	else if(heure<2 || heure==2&&minute<=20){printf("02:20");return 0;}
	else if(heure<3 || heure==3&&minute<=30){printf("03:30");return 0;}
	else if(heure<4 || heure==4&&minute<=40){printf("04:40");return 0;}
	else if(heure<5 || heure==5&&minute<=50){printf("05:50");return 0;}
	else if(heure<10 || heure==10&&minute<=1){printf("10:01");return 0;}
	else if(heure<11 || heure==11&&minute<=11){printf("11:11");return 0;}
	else if(heure<12 || heure==12&&minute<21){printf("12:21");return 0;}
	else if(heure<13 || heure==13&&minute<=31){printf("13:31");return 0;}
	else if(heure<14 || heure==14&&minute<=41){printf("14:41");return 0;}
	else if(heure<15 || heure==15&&minute<=51){printf("15:51");return 0;}
	else if(heure<20 || heure==20&&minute<=2){printf("20:02");return 0;}
	else if(heure<21 || heure==21&&minute<=12){printf("21:12");return 0;}
	else if(heure<22 || heure==22&&minute<=22){printf("22:22");return 0;}
	else if(heure<23 || heure==23&&minute<=32){printf("23:32");return 0;}
	else if(heure<24){printf("00:00");return 0;}
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
int rev(int a){
    return (a%10)*10+a/10;
}
int main()
{
    int i,h,m;
    scanf("%d:%d",&h,&m);
    if(h<=rev(m)){
        if(h==23)printf("00:00");
        else if(h>=0&&h<=5)printf("0%d:%d",h,rev(h));
        else if (h>=6&&h<=9)printf("10:01");
        else if(h>=15&&h<=19)printf("20:02");
        else printf("%d:%d",h+1,rev(h+1));
    }
    else {
        if(h>=0&&h<=5)printf("0%d:%d",h,rev(h));
        else if (h>=6&&h<=9)printf("10:01");
        else if(h>=16&&h<=19)printf("20:02");
        else printf("%d:%d",h,rev(h));
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int reverse(int a){
	int one,ten;
	one=a%10;
	ten=a/10;
	return one*10+ten;
}

int main(void)
{
	int hh,mm,h,hd;
	char syn[6];
	scanf("%s",syn);
	syn[2]='\0';
	hh=atoi(syn);
	mm=atoi(&syn[3]);
	h=hh%10;
	hd=hh/10;
	if(h<=5){
		if(mm>=reverse(hh))printf("%02d:%02d\n",(hh+1)%24,reverse((hh+1)%24));
		else printf("%02d:%02d\n",(hh)%24,reverse((hh)%24));
	}
	else{
		printf("%d0:0%d\n",hd+1,hd+1);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

void imprimirhora(int hora);
int main()
{
    int hora,minutos,h4=0;
    int I;
    int pal[]={0,110,220,330,440,550,660,770,880,990,1001,1111,1221,1331,1441,1551,2002,2112,2222,2332};

    scanf("%d:%d",&hora,&minutos);

    h4=(hora*100)+minutos;
    //printf("\n%d\n",h4);

    for(I=0;I<=19;I++)
    {
        if(pal[I]==h4&& !2332)
        {
            imprimirhora(pal[I+1]);
            break;
        }
        else if(h4<=59)
        {
            printf("01:10");
            break;
        }
        else if(pal[I]>h4)
        {
            imprimirhora(pal[I]);
            break;
        }
    }
    if(h4>=2332)
    {
        printf("00:00");
    }

    return 0;
}

void imprimirhora(int hora)
{
    int prh=0,prm=0;

        prh=hora/100;
        if (prh<10)
        {
            printf("0");
        }
        printf("%d",prh);

        prm=hora-(prh*100);
        if (prm<10)
        {
            printf(":0");
            printf("%d",prm);
        }
        else
        {
            printf(":%d",prm);
        }

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void cargar_matriz(char **matriz, int cant_pal);

int crear_matriz();

void funcion(char **matriz, int cant_pal);

int main()
{
    int cant_pal;
    cant_pal = crear_matriz();
    char *matriz[cant_pal];
    cargar_matriz(matriz,cant_pal);
    funcion(matriz,cant_pal);
    imprimir(matriz,cant_pal);

    return NULL;
}

void funcion(char **matriz, int cant_pal)
{
    int i;

    for( i = 0 ; i < cant_pal ; i++)
    {

        if(strlen(matriz[i]) > 10)
        {
            abreviar(matriz[i]);
        }
    }
    return NULL;
}

void abreviar(char *palabra)
{
    char palabra_nueva[50],aux[50];

    int n,i = 0,BAND=1;
    n = strlen(palabra)-2;
    palabra_nueva[0] = palabra[0];
    palabra_nueva[1] = '\0';
    itoa(n,aux,10);
    strcat(palabra_nueva,aux);
    n=strlen(palabra_nueva);
    palabra_nueva[n] = palabra [ (strlen(palabra)) - 1 ];
    palabra_nueva[n+1] = '\0';
    strcpy(palabra,palabra_nueva);

}

void imprimir(char **matriz,int cant_pal)
{
    int i = 0;

    for( i = 0 ; i < cant_pal ; i++)
    {

        printf("\n%s",matriz[i]);
    }

    return NULL;
}

void cargar_matriz(char **matriz, int cant_pal)
{
    char palabra[100];
    int i = 0;
    for( i = 0 ; i < cant_pal ; i++)
    {
        scanf("%s",palabra);
        if( ( matriz[i] = (char *) malloc ( 1 + (sizeof(char) * strlen(palabra)) )   ) == NULL )
        {
            printf("\nno hay espacio suficiente ");
            return NULL;
        }
        strcpy(matriz[i],palabra);
    }

    return NULL;
}

int crear_matriz()
{
    int n;
    printf("ingrese la cantidad de palabras :");
    scanf("%d",&n);
    return n;
}

#include <stdio.h>

#define sf scanf
#define sfi1(a) scanf("%d", &a)
#define sfi2(a,b) scanf("%d %d", &a, &b)
#define sfi3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sfi4(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define sfll1(a) scanf("%lld", &a)
#define sfll2(a,b) scanf("%lld %lld", &a, &b)
#define sfll3(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define sfll4(a,b,c,d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define sfc1(a) scanf("%c", &a)
#define sfc2(a,b) scanf("%c %c", &a, &b)
#define sfc3(a,b,c) scanf("%c %c %c", &a, &b, &c)
#define sfc4(a,b,c,d) scanf("%c %c %c %c", &a, &b, &c, &d)
#define sfd1(a) scanf("%lf", &a)
#define sfd2(a,b) scanf("%lf %lf", &a, &b)
#define sfd3(a,b,c) scanf("%lf %lf %lf", &a, &b, &c)
#define sfd4(a,b,c,d) scanf("%lf %lf %lf %lf", &a, &b, &c, &d)
#define pf printf
#define loop(i,n) for(int i=0; i<n; i++)
#define rloop(i,n) for(int i=n-1; i>=0; i--)

#define INF 100000000000ll
#define MOD 1000000007ll
#define test(d) cout << "test " << d << endl;
#define start(a,b) cout <<"---------start-----" << a << " " << b << "-----------\n";
#define testReturn(i,v) cout <<"return frm " << i << " : " << v << endl;
#define testFound(i,v) cout <<"found value " << i << " : " << v << endl;
#define testBaseRet(i,v) cout <<"return frm base condition " << i << " : " << v << endl;
#define MAXN 24

//variable
int t, h, m, r_h;

//method
int rev(int x){
    return ((x%10)*10 + x/10 );
}

void Print(){
    if(h<=9) pf("0%d::", h);
    else pf("%d::", h);
    if(r_h<=9) pf("0%d\n", r_h);
    else pf("%d\n", r_h);
}

int main(){
    //freopen("in_01.txt", "r", stdin);
    //freopen("out_01.txt", "w", stdout);
    //sfi1(t);
   // while(t--){
        scanf("%d::%d", &h, &m);
        r_h = rev(h);
        while(1){
            if(r_h > m ) {
                if(r_h <= 59) {Print(); break;}
                else{
                    h = ( (int) (h/10.0 + .5) ) * 10;
                    r_h = rev(h);
                    m = -1; continue;
                }
            } else{
                h = (h+1)% 24;
                r_h = rev(h);
                m = -1;
            }
        }
   // }
   // while(1);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int hora,Min;
    int Aux,i;
    float H;

    scanf("%d:%d",&hora,&Min);
    Min++;

    while(hora!=24){
        Aux=hora/10;
        H=(((float)hora/10)-Aux)*100+Aux;
        for (i=Min;Min<=60;Min++){
            if(H==Min){
                if(hora<10){
                    printf("0%d:",hora);
                }
                else{
                    printf ("%d:",hora);
                }
                if(Min<10){
                    printf("0%d",Min);
                }
                else{
                    printf ("%d",Min);
                }
                break;
            }
        }
        if(H==Min)
            break;
        hora++;
        Min=0;
    }
    if(hora==24)
        printf("00:00");

    return 0;

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char tiempo[6];
    char hora[3],minuto[3],hc[3],haux[2];
    int aux;
    scanf("%s",tiempo);

    hora[0]=tiempo[0];
    hora[1]=tiempo[1];
    hora[2]='\0';

    minuto[0]=tiempo[3];
    minuto[1]=tiempo[4];
    minuto[2]='\0';

    haux[1]='\0';

    hc[1]=tiempo[0];
    hc[0]=tiempo[1];
    hc[2]='\0';

    if(atoi(hora)<10)
    {
        if(atoi(hora)<6)
        {
            if(atoi(hc) > atoi(minuto))
            {
                strcpy(minuto,hc);
            }
            else
            {
                aux = atoi(hora)+1;
                itoa(aux,haux,10);
                hora[1] = haux[0];
                minuto[0]=hora[1];
                minuto[1]=hora[0];
            }
        }
        else
        {
            strcpy(hora,"10");
            strcpy(minuto,"01");
        }
    }
    else if(atoi(hora)==15 && atoi(minuto)>=52)
    {
        strcpy(hora,"20");
        strcpy(minuto,"02");
    }
    else if(atoi(hora)>15 && atoi(hora)<20)
    {
        strcpy(hora,"20");
        strcpy(minuto,"02");
    }
    else if(atoi(hc) > atoi(minuto))
    {
        strcpy(minuto,hc);
    }
    else if(atoi(hora) == 23)
    {
        strcpy(hora,"00");
        strcpy(minuto,"00");
    }
    else
    {
        aux = atoi(hora)+1;
        itoa(aux,hora,10);
        minuto[0]=hora[1];
        minuto[1]=hora[0];
    }
    printf("%s:",hora);
    printf("%s",minuto);
    return 0;
}

#include <stdio.h>

void buscar_hora(int *hora, int *minuto);

void imprimir(int hora, int minuto);

int main()
{
    int hora,minuto, hora_d, hora_u;
    scanf("%d%*c%d",&hora,&minuto);
    buscar_hora(&hora,&minuto);

    imprimir(hora,minuto);

    return NULL;
}

void buscar_hora(int *hora, int *minuto)
{
    int hora_d, hora_u, minuto_d, minuto_u, max_h = 23, max_m = 59;
    hora_d = (*hora)/10; hora_u = (*hora)%10;
    minuto_d =(*minuto)/10; minuto_u = (*minuto)%10;

    if (  (*hora > 22)  &&  (*minuto > 31) )
    {
        *hora = 0; *minuto = 0;
        return NULL;
    }
    if(  *minuto < (hora_d) + (hora_u*10)    )
    {
        if( (hora_d*10 +hora_u) < 16 || (hora_d*10 +hora_u) > 19)
        {
            *minuto = hora_d + (hora_u*10);
            return NULL;
        }
        else
        {
            *hora = 20;
            *minuto = 2;
            return NULL;
        }

        return NULL;
    }
    else
    {
        if(*hora < 15 || *hora > 18)
        {
            *hora=*hora +1;
            *minuto = (*hora)/10 + ((*hora)%10)*10;
            return NULL;
        }
        else
        {
            *hora = 20;
            *minuto = 2;
            return NULL;
        }

    }
    return NULL;
}

void imprimir(int hora, int minuto)
{
    int a = 0;
    if( hora == 0 && minuto == 0)
    {
        printf("%d%d:%d%d",hora,hora,minuto,minuto);
        return NULL;
    }
    if( hora == 0 && minuto < 10)
    {
        printf("%d%d:%d%d",hora,hora,a,minuto);
        return NULL;
    }
    if(hora <10 && minuto == 0)
    {
        printf("%d%d:%d%d",a,hora,minuto,minuto);
        return NULL;
    }
    if(hora < 10 && minuto < 10)
    {

        printf("%d%d:%d%d",a,hora,a,minuto);
        return NULL;
    }
    if(minuto < 10)
    {
        printf("%d:%d%d",hora,a,minuto);
        return NULL;
    }
    if(hora < 10)
    {
        printf("%d%d:%d",a,hora,minuto);
        return NULL;
    }
    printf("%d:%d",hora,minuto);

}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int h1, h2, m1, m2, hora, minuto, m_invertido;
    h1 = getchar() - '0';
    h2 = getchar() - '0';
    hora = h1 * 10 + h2;
    getchar();
    m1 = getchar() - '0';
    m2 = getchar() - '0';
    minuto = m1 * 10 + m2;

    m_invertido = h2 * 10 + h1;
    if(m_invertido < 60 && m_invertido > minuto)
    {
        printf("%d%d:%d%d", h1, h2, h2, h1);
    }
    else if(m_invertido >= 60 || (hora == 15 && minuto >= 51))
    {
        printf("20:02");
    }
    else
    {
        h2++;
        if(hora == 23)
        {
            h1 = 0;
            h2 = 0;
        }
        printf("%d%d:%d%d", h1, h2, h2, h1);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

void imprimirhora(int hora);
int main()
{
    int hora,minutos,h4=0;
    int I;
    int pal[]={0,110,220,330,440,550,1001,1111,1221,1331,1441,1551,2002,2112,2222,2332};

    scanf("%d:%d",&hora,&minutos);

    h4=(hora*100)+minutos;
    //printf("\n%d\n",h4);

    for(I=0;I<=16;I++)
    {
        if(pal[I]==h4&& !2332)
        {
            imprimirhora(pal[I+1]);
            break;
        }
        else if(h4<=59)
        {
            printf("01:10");
            break;
        }
        else if(pal[I]>h4)
        {
            imprimirhora(pal[I]);
            break;
        }
    }
    if(h4>=2332)
    {
        printf("00:00");
    }

    return 0;
}

void imprimirhora(int hora)
{
    int prh=0,prm=0;

        prh=hora/100;
        if (prh<10)
        {
            printf("0");
        }
        printf("%d",prh);

        prm=hora-(prh*100);
        if (prm<10)
        {
            printf(":0");
            printf("%d",prm);
        }
        else
        {
            printf(":%d",prm);
        }

}

#include <stdio.h>
#include <stdlib.h>
int ok(int a,int b)
{
    if(a/10!=b%10)return 0;
    if(a%10!=b/10)return 0;
    return 1;
}
void next(int *a,int *b)
{
     (*b)++;
     *a+=*b/60;
     *b%=60;
     *a%=60;
}
int main()
{
    int a,b;
    scanf("%d:%d",&a,&b);
    do{next(&a,&b);}while(!ok(a,b));
    printf("%d%d:%d%d\n",a/10,a%10,b/10,b%10);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int hora,Min;

    scanf("%d:%d",&hora,&Min);
    int Aux;
    float H;

    if((hora>0 && hora <=5 && Min<=50 )||(hora>=10 && hora<=15 && Min<=51)||(hora>=20 && hora<=23 && Min<=32)){
        Aux=hora/10;
        H=(((float)hora/10)-Aux)*100+Aux;
        if(Min<H)
            printf("%d:%.0f",hora,H);
        else{
            hora++;
            H=H+10;
            printf("%d:%.0f",hora,H);
        }
    }
    else if (hora>=6 && hora<=9)
        printf("10:01");
    else if (hora>=16 && hora<=19)
        printf("20:02");
    else
        printf("00:00");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

void imprimirfecha(int fecha);
int main()
{
    int hora,minutos,h4=0;
    int I;
    int pal[]={0,110,220,330,440,550,660,770,880,990,1001,1111,1221,1331,1441,1551,2002,2112,2222,2332};

    scanf("%d:%d",&hora,&minutos);

    h4=(hora*100)+minutos;
    //printf("\n%d\n",h4);

    for(I=0;I<=19;I++)
    {
        if(pal[I]==h4&& !2332)
        {
            imprimirfecha(pal[I+1]);
            break;
        }
        else if(h4<=59)
        {
            printf("01:10");
            break;
        }
        else if(pal[I]>h4)
        {
            imprimirfecha(pal[I]);
            break;
        }
    }
    if(h4>=2332)
    {
        printf("00:00");
    }

    return 0;
}

void imprimirfecha(int fecha)
{
    int prh=0,prm=0;

        prh=fecha/100;
        if (prh<10)
        {
            printf("0");
        }
        printf("%d",prh);

        prm=fecha-(prh*100);
        printf(":%d",prm);

}

#include<stdio.h>
int main(void)
{
    int a,h,m;
    scanf("%d:%d",&h,&m);
    if(h!=23)
    {
             h++;
             m=h;
             a=m%10;
             m/=10;
             m=a*10+m;
             printf("%d:%d\n",h,m);
    }
    else
        printf("00:00\n");

    return 0;
}

#include <stdio.h>
int main()
{
    char c[10];
    scanf("%s", c);
    int num1=10*(c[0]-'0')+(c[1]-'0');
    int num2=10*(c[3]-'0')+(c[4]-'0');
    //printf("%d %d", num1, num2);
    int ttemp=num1;
    int pnum1=0;
    while(ttemp)
    {
        int temp=ttemp%10;
        pnum1*=10;
        pnum1+=temp;
        ttemp/=10;
    }
    if(num1/10==0)
        pnum1*=10;
    //printf(" %d\n", pnum1);
    if(num2<pnum1 && pnum1<=60)
        printf("%d:%d\n", num1, pnum1);
    else
    {
        while(1)
        {
            num1+=1;
            num1%=24;
            ttemp=num1;
            pnum1=0;
            while(ttemp)
            {
                int temp=ttemp%10;
                pnum1*=10;
                pnum1+=temp;
                ttemp/=10;
            }
            if(num1/10==0)
                pnum1*=10;
            //printf("num1=%d pnum1=%d\n", num1, pnum1);
            if(pnum1<=60)
            {
                if(num1/10==0)
                {
                    if(pnum1/10==0)
                    {
                        printf("0%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("0%d:%d\n", num1, pnum1);
                }
                else
                {
                    if(pnum1/10==0)
                    {
                        printf("%d:0%d\n", num1, pnum1);
                    }
                    else
                        printf("%d:%d\n", num1, pnum1);
                }
                break;
            }
        }
    }
}

#include<stdio.h>
#include<math.h>
#define pi 3.1415926535897932
int main()
{
    double Area,n,r;
    scanf("%lf%lf",&n,&r);

    Area=(n*r*r)/((1/tan(pi/(2*n))) + (1/tan(pi/n)));

    printf("%.12lf",Area);
    return 0;
}

#include <stdio.h>

int main()
{
    int hora,minuto, hora_d, hora_u;
    scanf("%d%*c%d",&hora,&minuto);
    hora_d = hora/10;
    hora_u = hora%10;

    if(hora > 22  &&  minuto > 31)
    {
        hora = 0;
        minuto = 0;

    }
    else
    {
        if(minuto < (hora_d + (hora_u *10) ) )
        {
            minuto = hora_d + (hora_u*10);
        }
        else
        {
            hora = hora +1;
            minuto = hora/10 + (hora%10)*10;
        }

    }
    if(hora == 0)
    {
        if(minuto == 0)
        {
            printf("%d%d:%d%d",hora,hora,minuto,minuto);
        }
        else
        {
            printf("%d%d:%d",hora,hora,minuto);
        }
        return NULL;

    }
    else
    {
        if(minuto == 0)
        {
            printf("%d:%d%d",hora,minuto,minuto);

            return NULL;
        }

    }
    printf("%d:%d",hora,minuto);

return NULL;
}