#include<stdio.h>
int main(){
int H , M , a , s ;
char c;
scanf("%d %c %d",&H,&c,&M);
scanf("%d",&a) ;
s=H*60 + M + a ;
H=(s/60)%24;
M=s%60;
printf("%02d:%02d",H,M);
return 0 ;
}

#include <stdio.h>

int main()
{
    int hh,mm;
    scanf("%d:%d",&hh,&mm);

    int a;
    scanf("%d",&a);
    int hr,min;
    hr = a/60;
    for( ;hr>24; ) {
        hr = hr-24;
    }
    //printf("\n\nhr = %d",hr);

    min = a%60;
    for( ;min>60; ) {
        min = min/60;
    }
    //printf("\n\nmin = %d",min);

    int f_hr,f_m;
    f_hr = hh+hr;//printf("\n\nf_hr = %d",f_hr);
    f_m = mm+min;//printf("\n\nf_m = %d",f_m);

    if(f_m>59) {
        f_hr = f_hr+1;//printf("\n\nf_hr = %d",f_hr);
        f_m = f_m-60;//printf("\n\nf_m = %d\n\n",f_m);
    }

    if(f_hr>=24)
        f_hr = f_hr-24;
    if(f_hr<10 && f_m<10)
        printf("0%d:0%d",f_hr,f_m);
    else if(f_hr<10 && f_m>=10)
        printf("0%d:%d",f_hr,f_m);
    else if(f_hr>=10 && f_m<10)
        printf("%d:0%d",f_hr,f_m);
    else
        printf("%d:%d",f_hr,f_m);

    return 0;

}

#include <stdio.h>

int main(void){
	int H, M, min;
	scanf("%d:%d", &H, &M);
	scanf("%d", &min);
	H = (H+(M+min)/60)%24;
	M = (M+min)%60;
	printf("%02d:%02d", H, M);
	return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int i, j, k, h, m;
    while (scanf("%d:%d", &h, &m) != EOF){
        scanf("%d", &k);
        int t = ((h * 60) + m + k) % (24 * 60);
        printf("%02d:%02d\n", t / 60, t % 60);
    }
    return 0;
}

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

int main()
{
	char achCurTime[10];

	int iCurHr;
	int iCurMin;

	int iPlusMin;

	int iNewMin;
	int iNewHr;

	scanf("%s", achCurTime );

	achCurTime[2] = 0;

	sscanf( &achCurTime[0] , "%d", &iCurHr );
	sscanf( &achCurTime[3] , "%d", &iCurMin );

	scanf("%d", &iPlusMin );

	iNewMin = iCurMin + iPlusMin;

	iNewHr = iNewMin / 60;
	iNewMin = iNewMin % 60;

	iNewHr += iCurHr;

	iNewHr %= 24;

	printf("%02d:%02d\n",iNewHr , iNewMin );

	return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
    char time[6];
    int hr,min,h,m,a;
    scanf("%s",time);
    sscanf(time,"%d:%d",&hr,&min);
    scanf("%d",&a);
   // printf("%d %d",hr,min);
    h=a/60;
    m=a%60;
    if((min+m)>=60)
    {
        min=min+m-60;
        h++;
    }
    else
    min=min+m;
    hr=(hr+h)%24;
    printf("%02d:%02d",hr,min);
    return 0;
}

#include<stdio.h>
int main()
{
    int hh,mm,a,m;
    char ch;
    scanf("%d%c%d",&hh,&ch,&mm);
    scanf("%d",&a);
    m=mm+a;
    if(m>59)
    {
        mm=m%60;
        hh=m/60+hh;
        m=mm;
    }
    while(hh>23)
    {
        hh=hh-24;
    }
    printf("%02d%c%02d\n",hh,ch,m);
    return 0;
}

#include <stdio.h>
void ajoutminute(int *hh,int *mm,int a){
int s=(*hh)*60+ (*mm);
s=s+a;
*hh=s/60;
*mm=(s%60);
if (*hh>23)
 (*hh)=(*hh)%24;
}

int main(){
 int mm, hh, a;
 scanf("%d:%d ",&hh,&mm);
 scanf("%d",&a);
 ajoutminute(&hh,&mm,a);

if(mm<=9 && hh<=9)
 	printf("0%d:0%d",hh,mm);
else if(mm>9 && hh>9)
	printf("%d:%d",hh,mm);
else if(mm>9 && hh<=9)
	printf("0%d:%d",hh,mm);
else
	printf("%d:0%d",hh,mm);

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 */
char c;
int h,m,n,a,b;
int main(int argc, char *argv[]) {
	scanf("%d%c%d%d",&h,&c,&m,&n);
	a=n/60;
	n%=60;
	h+=a;
	m+=n;
	if(m>=60)
	{h++;m%=60;}
	h%=24;
	if(h>=10&&m>=10)printf("%d:%d\n",h,m);
	if(h<10&&m>=10)printf("0%d:%d\n",h,m);
	if(h>=10&&m<10)printf("%d:0%d\n",h,m);
	if(h<10&&m<10)printf("0%d:0%d\n",h,m);
	return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,i,j,k,n;
    char x;
    scanf("%d%c%d%d",&a,&x,&b,&n);
    j=b+n;
    i=j/60;
    b=j%60;
    a=a+i;
    a=a%24;
    if(a<10)
        printf("0%d",a);
    else
        printf("%d",a);
    if(b<10)
        printf(":0%d",b);
    else
        printf(":%d",b);

}

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

mm=mm+a%60;
if(mm>59){
    mm=mm%60;
    hh+=1;
}
hh=hh+a/60;
if (hh>23){
 hh=hh%24;
}
printf("%02d:%02d",hh,mm);

return 0;
}

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

int main()
{
    int hh,mm;
    int a;
    scanf("%d:%d%d",&hh,&mm,&a);
    mm+=a%60;
    if(mm>=60) {hh+=1;mm%=60;}
    hh+=(a/60);
    if(hh>=24) hh%=24;
    printf("%02d:%02d\n",hh,mm);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[10];
    int add,h,m,hour,min,temp;
    scanf("%s",a);
     scanf("%d",&add);
    //printf("%d %d %d %d\n",a[0]-48,a[1]-48,a[3]-48,a[4]-48);
    h=(10*(int)(a[0]-48))+(int)(a[1]-48);
    m=(10*(int)(a[3]-48))+(int)(a[4]-48);

    if(add==0)
    {
        printf("%s",a);
        return 0;
    }

    //printf("h=%d m=%d\n",h,m);
    temp=(m+add)/60;
    //printf("adder in hours=%d\n",temp);
    min=(m+add)%60;
    hour=(h+temp)%24;

    //printf("hour=%d\n",hour);

    if(hour<10)
        printf("0%d:",hour);
    else
        printf("%d:",hour);
    if(min<10)
        printf("0%d\n",min);
    else
        printf("%d\n",min);

    return 0;
}

#include <stdio.h>

main(){
    char time[6]; int a;
    scanf ("%[^\n]%*c", time);
    scanf ("%d",&a);
    int b=time[0]-48;
    int c=time[1]-48;
    int atimeh=b*10 + c;

    int d=time[3]-48;
    int e=time[4]-48;
    int atimem=d*10+e;

    int hours= a/60;
    int mins= a%60;

    int ahours= hours%24;

    int result1= ((atimeh+ahours) + ((atimem+mins)/60))%24;
    int result2=  (atimem+mins)%60;
    if (result1<10 && result2<10)
    printf("0%d:0%d",result1,result2);

    else if (result1<10 && result2>=10)
    printf("0%d:%d",result1,result2);

    else if (result1>=10 && result2<10)
    printf("%d:0%d",result1,result2);

    else
    printf("%d:%d",result1,result2);

}

#include <stdio.h>
int a,b;
long long n;
int main()
{
	scanf("%d:%d",&a,&b);
	scanf("%I64d",&n);
	b+=n;
	a+=b/60;
	b%=60;
    a%=24;
    if(a<10)printf("0%d:",a);
    else printf("%d:",a);
    if(b<10)printf("0%d",b);
    else printf("%d",b);
    return 0;

}

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

int main()
{

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

    h=(h+(m+a)/60)%24;
    m=(m+a)%60;

    printf("%0.2d:%0.2d",h,m);

   return(0);
}

#include<stdio.h>
main()
{

int a,b;
char c;
scanf("%d%c%d",&a,&c,&b);
int num;
scanf("%d",&num);

b+=num;
int tmp=b/60;
b%=60;
a+=tmp;
a%=24;
printf("%02d%c%02d",a,c,b);
}

#include<stdio.h>
int main()
{
    char c;
    int h, min, addh, addm, finh;
    scanf("%d%c%d", &h, &c, &min);
    int add;
    scanf("%d", &add);
    addh=(min+add)/60;
    addm=(min+add)%60;
   // printf("%d\n", addm);
    finh=addh+h;
    if(finh>=24)
    {
        finh%=24;
    }
    printf("%02d:%02d", finh, addm);
    return 0;
}

#include <stdio.h>

int main() {
	int hh, mm, a;

	scanf("%d:%d", &hh, &mm);
	scanf("%d", &a);
	mm += a;
	if (mm >= 60) {
		int min = mm / 60;

		mm %= 60;
		hh += min;
		if (hh >= 24)
			hh %= 24;
	}
	printf("%02d:%02d\n", hh, mm);
	return 0;
}

// The Time

#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[6];
	int a,i,arr_h[3],arr_m[3],hh,mm,x,y,time;
	scanf("%s",str);
	char str_h[3] = "",str_m[3] = "";
	scanf("%d",&a);
	for(i = 0;i<2;i++)
	{
		if(str[i]=='0')
			strcat(str_h,"0");
		else if(str[i]=='1')
			strcat(str_h,"1");
		else if(str[i]=='2')
			strcat(str_h,"2");
		else if(str[i]=='3')
			strcat(str_h,"3");
		else if(str[i]=='4')
			strcat(str_h,"4");
		else if(str[i]=='5')
			strcat(str_h,"5");
		else if(str[i]=='6')
			strcat(str_h,"6");
		else if(str[i]=='7')
			strcat(str_h,"7");
		else if(str[i]=='8')
			strcat(str_h,"8");
		else if(str[i]=='9')
			strcat(str_h,"9");
	}

	for(i = 3;i<=4;i++)
	{
		if(str[i]=='0')
			strcat(str_m,"0");
		else if(str[i]=='1')
			strcat(str_m,"1");
		else if(str[i]=='2')
			strcat(str_m,"2");
		else if(str[i]=='3')
			strcat(str_m,"3");
		else if(str[i]=='4')
			strcat(str_m,"4");
		else if(str[i]=='5')
			strcat(str_m,"5");
		else if(str[i]=='6')
			strcat(str_m,"6");
		else if(str[i]=='7')
			strcat(str_m,"7");
		else if(str[i]=='8')
			strcat(str_m,"8");
		else if(str[i]=='9')
			strcat(str_m,"9");
	}

	hh = 0;
	x = 10;
	for(i = 0;i<2;i++)
	{
		if(str_h[i]=='0')
			arr_h[i] = 0;
		else if(str_h[i]=='1')
			arr_h[i] = 1;
		else if(str_h[i]=='2')
			arr_h[i] = 2;
		else if(str_h[i]=='3')
			arr_h[i] = 3;
		else if(str_h[i]=='4')
			arr_h[i] = 4;
		else if(str_h[i]=='5')
			arr_h[i] = 5;
		else if(str_h[i]=='6')
			arr_h[i] = 6;
		else if(str_h[i]=='7')
			arr_h[i] = 7;
		else if(str_h[i]=='8')
			arr_h[i] = 8;
		else if(str_h[i]=='9')
			arr_h[i] = 9;

		hh += x*arr_h[i];
		x/=10;
	}

	mm = 0;
	y = 10;
	for(i = 0;i<2;i++)
	{
		if(str_m[i]=='0')
			arr_m[i] = 0;
		else if(str_m[i]=='1')
			arr_m[i] = 1;
		else if(str_m[i]=='2')
			arr_m[i] = 2;
		else if(str_m[i]=='3')
			arr_m[i] = 3;
		else if(str_m[i]=='4')
			arr_m[i] = 4;
		else if(str_m[i]=='5')
			arr_m[i] = 5;
		else if(str_m[i]=='6')
			arr_m[i] = 6;
		else if(str_m[i]=='7')
			arr_m[i] = 7;
		else if(str_m[i]=='8')
			arr_m[i] = 8;
		else if(str_m[i]=='9')
			arr_m[i] = 9;

		mm += y*arr_m[i];
		y/=10;
	}

	time = 60*hh+mm;
	time = time+a;

	time = time%1440;

	hh = time/60;

	if(hh==24)
		hh = 0;

	mm = time%60;

	if((hh>=0)&&(hh<=9))
		printf("0%d:",hh);
	else
		printf("%d:",hh);

	if((mm>=0)&&(mm<=9))
		printf("0%d",mm);
	else
		printf("%d",mm);

	printf("\n");
	return 0;
}

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

int main()
{
    int hh,mm,a;
    scanf("%d:%d",&hh,&mm);
   scanf("%d",&a);
    int seconds=60*mm+3600*hh+a*60;
    seconds%=86400;
    hh=seconds/3600;
    seconds%=3600;
    mm=seconds/60;
    printf("%02d:%02d",hh,mm);
    return 0;
}

#include <stdio.h>
int hh,mm,a;
int main(){
	scanf("%d:%d",&hh,&mm);
	scanf("%d",&a);
	mm=mm+a;
	if(mm>=60){
        hh=hh+(mm/60);
		mm=mm%60;

	      }
    if(hh>=24){
		hh=(hh%24);
		}
 printf("%02d:%02d",hh,mm);

return 0;
}

#include<stdio.h>

int main()
{
	int hh, mm, a, ans_h, ans_m;
	scanf("%d:%d", &hh, &mm);
	scanf("%d", &a);
	ans_m = (mm+a)%60;
	ans_h = (hh + ((mm+a)/60))%24;
	printf("%.2d:%.2d\n", ans_h, ans_m);
	return 0;
}

#include <stdio.h>
int main()
{
    int h,m,a;
    scanf("%d:%d",&h,&m);
    scanf("%d",&a);
    int t=h*60+m+a;
    //printf("%d",t);
    t%=1440;
    h=t/60;
    m=t%60;
    if(h<10)
        printf("0%d",h);
    else
        printf("%d",h);

    if(m<10)
        printf(":0%d",m);
    else
        printf(":%d",m);

    return 0;
}

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

int main()
{
    int hh,mm;
    char c;
    int a;
    scanf("%d %c %d",&hh, &c,&mm);
    scanf("%d",&a);
    mm=mm+a;
    if (mm>59){
        hh=(hh+mm/60)%24;
        mm=mm%60;
    }
    printf("%02d:%02d",hh,mm);
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#define pi acos(-1.0)

int min(int a,int b){int x=a>b?b:a; return x;}
int max(int a,int b){int x=a>b?a:b; return x;}
int digit(int x)
{
	int count=0;
	while(x!=0)
	{
		x=x/10;
		count++;
	}
	return count;
}
int gcd(int a,int b)
{
	int i,GCD;
	for(i=1;i<=a&&i<=b;i++)
	{
		if(a%i==0&&b%i==0)
		GCD=i;
	}
	return GCD;
}
int lcm(int a,int b){int LCM=(a*b)/gcd(a,b); return LCM;}
int main()
{
	int h,m,s,am,ah;
	scanf("%d:%d",&h,&m);
	scanf("%d",&s);
	ah=s/60;
	am=s-(ah*60);
	int mi=am+m;
	if(mi>=60)
	{
		ah++;
		mi=mi-60;
	}
	int ho=(ah+h)%24;
	if(ho<10)
	printf("0%d",ho);
	else
	printf("%d",ho);
	if(mi<10)
	printf(":0%d",mi);
	else
	printf(":%d",mi);
	return 0;
}

#include <stdio.h>

int main() {
	int hour, min , dop;
	scanf("%d:%d %d",&hour, &min, &dop);
	min+= hour*60+dop;
	printf("%.2d:%.2d",(min / 60) % 24, min % 60);
	return 0 ;
}

#include <stdio.h>

int main(){

    int H = 24;
    int M = 60;

    int h, m, a; scanf("%ld:%ld\n%ld", &h, &m, &a);

    m += a;
    h += m / M;
    m %= M;
    h %= H;

    printf("%02ld:%02ld\n", h, m);

    return 0;
}

#include<stdio.h>
int main()
{
	int h,min,after,nh,nmin;
	scanf("%d:%d",&h,&min);
	scanf("%d",&after);
	nh=after/60;
	nmin=after%60;
	h=h+nh;
	min=min+nmin;
	if(min>=60)
	{
		min=min-60;
		h++;
	}
	if(h>=24)
	h=h%24;
	printf("%02d:%02d",h,min);

	return 0;
}

#include<stdio.h>
int hh, mm, a, p;

int main()
{
	scanf("%d:%d %d", &hh, &mm, &a);

	p = hh * 60 + mm + a;
	mm = p % 60;
	hh = p / 60;
	if (hh>23){
	    hh = hh % 24;
	}
	printf("%02d:%02d", hh, mm);

	return 0;
}

#include<stdio.h>
int main()
{
    char s;
    unsigned int a,c,d;
    scanf("%d%c%d",&c,&s,&d);
    int hour=0,min=0,i,b=0;
    hour = hour + c;
    min=min + d ;
    /*char s[2];
    int hour[2],min[2],b=0,c=0,i; unsigned int a;
    for(i=0;i<)*/
    scanf("%u",&a);
    while(a--)
    {
        min++;
        if(min==60)
        {
            hour++; min=0;
            if(hour==24)
            {
                hour=0;
            }
        }
    }
    if(hour<=9) printf("0%d:",hour);
    else printf("%d:",hour);
    if(min<=9) printf("0%d\n",min);
    else printf("%d\n",min);
    return 0;
}

#include<stdio.h>
int main(int argc, char const *argv[])
{
	long long hr, min, next;
	scanf("%lld:%lld %lld",&hr,&min,&next);
	next = hr*60 + next + min;
	printf("%.2lld:%.2lld\n", (next/60)%24 , next%60);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int h,m,a,i,ans,hour,minute;
    scanf("%d:%d",&h,&m);
    scanf("%d",&a);
    m+=a;
    h+=m/60;
    m=m%60;
    printf("%02d:%02d",h%24,m);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
int m,h,a,s,r,x,y;
char c;
scanf("%d  %c  %d",&h,&c,&m);
scanf("%d",&a);
s=a%60;
r=a/60;
h=h+r;
m=m+s;
x=m%60;
h=h+(m/60);
y=h%24;
printf("%02d:%02d",y,x);
return 0;
}

#include <stdio.h>
int main(){
	int hh,mm,a,b,q,reste,c;
	scanf("%d:%d",&hh,&mm);
	scanf("%d",&a);
	b=mm+a;
	if(b<60)
	  { printf("%02d:%02d",hh,b);}
	else {
		   reste=b%60;
		   q=b/60;
		   c=hh+q;
		   if (c<24)
		      printf("%02d:%02d",q+hh,reste);
		   else {
			      printf("%02d:%02d",c%24,reste);
			   }
		}
	return 0;}

#include<stdio.h>

main()
{
    int hh,mm,in,h,m;

        scanf("%d:%d",&hh,&mm);
        scanf("%d",&in);
        h = in/60;
        m = in%60;
        hh = hh+h;
        mm = mm+m;
        if(mm>=60)
        {
            hh+=1;
            mm = mm%60;
        }
        if(hh>=24)
        {
            hh = hh%24;
        }
        printf("%02d:%02d\n",hh,mm);

 return 0;
}

#include <stdio.h>
int main()
{
	char string[10];
	scanf("%s", string);
	int i;
	int hours=(string[0]-'0')*10+string[1]-'0';
	int minutes=(string[3]-'0')*10+string[4]-'0';
//	printf("%d %d\n",hours,minutes );
	int n;
	scanf("%d", &n);
	if(n==60)
	{
		if(hours!=23)
			hours++;
		else
			hours=00;
	}
	else
	{
		int hrs=n/60;
		int mins=n-hrs*60;

		for(i=1;i<=mins;i++)
		{
			if(minutes<59)
				minutes++;
			else if(minutes==59)
				{
					if(hours!=23)
				hours++;
			else
				hours=0;
					minutes=0;
				}
		}
		for(i=1;i<=hrs;i++)
		{
			if(hours!=23)
				hours++;
			else
				hours=0;
		}

	}
	if(hours<10)
	{
		printf("0");
		printf("%d", hours);
	}
	else
		printf("%d", hours);
	printf(":");
	if(minutes<10)
		{
			printf("0");
			printf("%d", minutes);
		}
	else
		printf("%d", minutes);
	return 0;

}

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

int main()
{
    int h,m;
    char o;
    int mm;
    scanf("%d%c%d",&h,&o,&m);
    scanf("%d",&mm);
    int cnt=0;
    for(int i=0;i<200;i++)
    {
        if(mm-60>0)
        {
            mm=mm-60;
            cnt++;
            continue;
        }
        else
        break;
    }
    //printf("%d\n",mm);
    if(m+mm>=60)
    {
        cnt++;
        m=m+mm-60;
    }
    else
    m=m+mm;
    //printf("%d",cnt);
    h=h+cnt;
    if(h>24)
    {
        for(int i=0;i<1000;i++)
        {
            if(h-24>24)
            {
                h=h-24;
                continue;
            }
            else
            {
                h=h-24;
                break;
            }
        }
    }
    //printf("%d\n",h);
    if(h==24)
    {
        printf("00:");
    }
    else
    {
      if(h<10)
      printf("0");

    printf("%d:",h);
    }
    if(m<10)
    printf("0");
    printf("%d",m);

    return 0;
}

#include <stdio.h>
int main(){
	int hh,mm,a,d,r;
	char c;
	scanf("%d%c%d",&hh,&c,&mm);
	scanf("%d", &a);
	r=a%60;
	d=a/60;
	if (r+mm<60	)
		{mm=mm+r ;
		if (hh+d<24)
			hh=hh+d ;
			else
				hh=(hh+d)%24;}
	else {
		mm=(mm+r)-60 ;
		if (hh+d+1<24)
			hh=hh+d+1;
		else
		   hh=(hh+d+1)%24 ;}

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

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

void afficher(int);
int main()
{
    int h,m,t ;
    scanf("%d:%d \n %d" ,&h,&m ,&t);
    m+=t;
    h+=(m)/60 ;
    h%=24;
    m%=60;

    afficher(h);
    printf(":");
    afficher(m);
}

void afficher(int t)
{
    if (t<10)
        printf("0%d",t);
    else
        printf("%d",t);
}

#include<stdio.h>

int main()
{
        unsigned int h,m,a;
        char ch;

        scanf("%d%c%d",&h,&ch,&m);
        scanf("%d", &a);
        m+=a;
        if(m%60>=0)
        {
            h+=m/60;
            m=m%60;
            printf("%02d:%02d\n", h%24, m);
        }
        else
        {
            m+=a;
        printf("%02d:%02d\n", h%24, m);
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(){
int h,m,a;
scanf("%d:%d %d", &h, &m, &a);
a = a + h*60 + m;
printf("%.2d:%.2d", a/60%24, a%60);
return 0;
}

#include <stdlib.h>
#include <string.h>
int main()
{
    int hh,mm,x;
    scanf ("%d:%d %d",&hh,&mm,&x);
    mm+=x;
    hh=(hh+mm/60)%24;
    mm%=60;
    printf("%d%d:%d%d",hh/10,hh%10,mm/10,mm%10);
    return 0;
}

#include <stdio.h>

int main() {
    int h = 0;
    int m = 0;
    char c = 0;
    scanf("%d%c%d", &h, &c, &m);
    int num = 0;
    scanf("%d", &num);
    int all = h * 60 + m + num;
    h = (all / 60);
    m = (all - h * 60);
    h = h % 24;
    if (h < 10) {
        printf("0%d:", h);
    }
    else {
        printf("%d:", h);
    }
    if (m < 10) {
        printf("0%d", m);
    }
    else {
        printf("%d", m);
    }
    return 0;
}

#include<stdio.h>
int main(){
int H , M , a , s ;
char c;
scanf("%d %c %d",&H,&c,&M);
scanf("%d",&a) ;
s=H*60 + M + a ;
H=(s/60)%24;
M=s%60;
printf("%02d:%02d",H,M);
return 0 ;
}

#include<stdio.h>

main()
{
    int hh,mm,in,h,m;

        scanf("%d:%d",&hh,&mm);
        scanf("%d",&in);
        h = in/60;
        m = in%60;
        hh = hh+h;
        mm = mm+m;
        if(mm>=60)
        {
            hh+=1;
            mm = mm-60;
        }
        if(hh>=24)
        {
            hh = hh-24;
        }
        printf("%02d:%02d\n",hh,mm);

 return 0;
}

#include <stdio.h>
void ajoutminute(int *mm,int *hh,int a){
if(*mm+a>=60){
	if(*hh==23){
		*hh=0;
		*mm=-60+*mm+a;}
	else{
		*hh++;
		*mm=-60+*mm+a;}
	}
else
	*mm=*mm+a;

}

int main(){
 int mm, hh, a;
 scanf("%d:%d ",&hh,&mm);
 scanf("%d",&a);
 ajoutminute(&mm,&hh,a);
 if(mm<=9 && hh<=9)
 	printf("0%d:0%d",hh,mm);
else if(mm>9 && hh>9)
	printf("%d:%d",hh,mm);
else if(mm>9 && hh<=9)
	printf("0%d:%d",hh,mm);
else
	printf("%d:0%d",hh,mm);

return 0;}

#include <stdio.h>
int hh, mm, a;
int main(int argc, char **argv)
{
    scanf("%d:%d", &hh, &mm);
    scanf(" %d", &a);

    for(int i=0;i<a;i++){
        if(mm==60){
            mm=00;
            hh++;
            if(hh==24)
                hh=00;
        }
        mm++;
        if(mm==60)
            mm=00;
    }
    if(hh<10 || mm<10)
        printf("0%d:0%d\n",hh,mm);
    else
        printf("%d:%d\n",hh,mm);
}

#include<stdio.h>
main()
{

int a,b;

scanf("%d%d",&a,&b);
int num;
scanf("%d",&num);

b+=num;
int tmp=b/60;
b%=60;
a+=tmp;
a%=24;
printf("%02d:%02d",a,b);
}

#include <stdio.h>
void ajoutminute(int *mm,int *hh,int a){
if(*mm+a>=60){
	if(*hh==23){
		int d=a/60;
		int r=a%60;
		*hh=d;
		*mm=r-1;}
	else{
		int d=a/60;
		int r=a%60;
		*hh=*hh+d;
		*mm=*mm+r;}
	}
else
	*mm=*mm+a;
}

int main(){
 int mm, hh, a;
 scanf("%d:%d ",&hh,&mm);
 scanf("%d",&a);
 ajoutminute(&mm,&hh,a);
 if(mm<=9 && hh<=9)
 	printf("0%d:0%d",hh,mm);
else if(mm>9 && hh>9)
	printf("%d:%d",hh,mm);
else if(mm>9 && hh<=9)
	printf("0%d:%d",hh,mm);
else
	printf("%d:0%d",hh,mm);

return 0;}

#include <stdio.h>
#include <stdlib.h>
void horloge(int*heure , int*minute,int a ){
if (*minute+a<60)
    *minute=*minute+a;

else
    {*minute=(*minute+a)-(60*((*minute+a)/60)) ;
    if (*heure<23)
     *heure=*heure+((*minute+a)/60);
    else
        *heure=00;

}
}
int main()
{
    int a, heure,minute ;
    scanf("%d : %d",&heure,&minute);
    scanf("%d",&a);
    horloge(&heure,&minute,a);
    printf("%02d:%02d",heure,minute);
    return 0;
}

#include <stdio.h>

int main() {
	char times[5];
	int hours, mine;
	int new_mine;

	scanf("%s", times);
	scanf("%d", &new_mine);
	sscanf(times, "%d:%d", &hours, &mine);

	if (hours > 25 || hours < 0)
	{
		printf("ошибка\n");
	}
	if (mine > 60 || mine < 0)
	{
		printf("ошибка\n");
	}
	if (new_mine > 10000 || new_mine < 0)
	{
		printf("ошибка\n");
	}
/*-----------*/
	mine = mine + new_mine;

	if (mine > 59) {
		hours = hours + 1;
		mine = 60 - mine;
		mine = new_mine - mine -10;

	}
	if (hours >= 24) {
		hours= 0;
	}

	if (hours < 10)
	{
		printf("0%d:", hours);
	}
	if (mine < 10)
	{
		printf("0%d", mine);
	}
	else {
		printf("%d:%d\n", hours, mine);
	}
}

#include <stdio.h>

int main()
{
    int hr;
    int mnt;
    int tmp;
    scanf("%d:%d", &hr,&mnt);
    scanf("%d", &tmp);
    mnt = mnt + tmp;
    hr = hr + mnt/60;
    mnt = mnt%60;
    if (hr == 24)
       hr = 0;
    if (hr <10)
       printf("0%d:",hr);
    else
        printf("%d:",hr);
    if (mnt < 10)
       printf("0%d",mnt);
    else
        printf("%d",mnt);
    return 0;
}

#include<stdio.h>
int main(){
int H , M , a , s ;
char c;
scanf("%d %c %d",&H,&c,&M);
scanf("%d",&a) ;
s=H*60 + M + a ;
H=(s/60)%24;
M=(s/24)%60;
printf("%d:%d",H,M);
return 0 ;
}

#include <stdio.h>
void ajoutminute(int *mm,int *hh,int a){
if(*mm+a>=60){
	if(*hh==23){
		int d=a/60;
		int r=a%60;
		*hh=d;
		*mm=*mm+r;}
	else{
		int d=a/60;
		int r=a%60;
		*hh=*hh+d;
		*mm=*mm+r;}
	}
else
	*mm=*mm+a;
}

int main(){
 int mm, hh, a;
 scanf("%d:%d ",&hh,&mm);
 scanf("%d",&a);
 ajoutminute(&mm,&hh,a);
 if(mm<=9 && hh<=9)
 	printf("0%d:0%d",hh,mm);
else if(mm>9 && hh>9)
	printf("%d:%d",hh,mm);
else if(mm>9 && hh<=9)
	printf("0%d:%d",hh,mm);
else
	printf("%d:0%d",hh,mm);

return 0;}

#include<stdio.h>
int main(){
int H , M , a , s ;
char c;
scanf("%d %c %d",&H,&c,&M);
scanf("%d",&a) ;
s=H*60 + M + a ;
H=(s/60)%24;
M=s%60;
printf("%d:%d",H,M);
return 0 ;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
		int p,o;
		int a;
		int k,l,m,n;
		scanf("%d:%d\n",&p,&o);
		scanf("%d",&a);
		k=p/10;
		l=p%10;
		m=o/10;
		n=o%10;

		int x;
		x=a/60;
		int y;
		y=(10*k+l+x)%24;
		if(y<10)
		{
			k=0;
			l=y;
		}
		int z;
		z=a-60*x;
		int c;
		c=(10*m+n+z)%60;
		if(c<10)
		{
			n=c;
			m=0;
		}
		printf("%d%d:%d%d",k,l,m,n);
		return 0;
}

/*
 * main.c
 *
 * Copyright 2016 elmihailol <elmihailol@elmihailol-ubuntu>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <stdio.h>

int main(int argc, char **argv)
{
	int x, y, p;
	printf("Time: ");
	scanf("%d:%d", &x, &y);
	printf("Time+: ");
	scanf("%d", &p);
	y=y+p;
	while(y>=60)
	{
		x++;
		y-=60;
	}
	while(x>=24)
	{
		x-=24;
	}
	if(x<10 && y<10)
	{
		printf("0%d:0%d",x, y);
	}
	if(x<10 && y>=10)
	{
		printf("0%d:%d",x, y);
	}
	if(x>=10 && y<10)
	{
		printf("%d:0%d",x, y);
	}
	if(x>=10 && y>=10)
	{
		printf("%d:%d",x, y);
	}
	int i;

	return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
    char time[6];
    int hr,min,h,m,a;
    scanf("%s",time);
    sscanf(time,"%d:%d",&hr,&min);
    scanf("%d",&a);
   // printf("%d %d",hr,min);
    h=a/60;
    m=a%60;
    if((min+m)>=60)
    {
        min=min+m-60;
        h++;
    }
    else
    min=min+m;
    if((hr+h)>=24)
        hr=hr+h-24;
    else
        hr=hr+h;
    printf("%02d:%02d",hr,min);
    return 0;
}

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

 main()
{
    int t,h,s,i ,f;
    char v;
    f=t;
    scanf ("%d%c%d",&h,&v,&s);
    scanf("%d",&t);
    for (i=0;i<t;i++){
  s++;
    if(s==60){
       h=h+1;
        s=0;
}
         if(h==24)
        {
           h=0;
        }
}
    printf("%d:%d\n",h,s);
    return 0;
}

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

int main()
{
    int n,l,nb ;
    char s[100000];
    scanf("%d",&n);
    scanf("%s",&s);
    nb=n+1;
    printf("%d",nb);
    return 0;
}

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

int main()
{
    int a, h, x, m;
    scanf("%d:%d", &h, &m);
    scanf("%d", &a);
    m += a;
    x = m / 60;
    m %= 60;
    h += x;
    h %= 24;
    if (h > 10) printf("%d", h);
    else printf("0%d", h);
    printf(":");
    if (m > 10) printf("%d\n", m);
    else printf("0%d\n", m);
    return 0;
}

#include <stdio.h>

int main()
{
    int mm,hh,m1;
    char k;
    scanf("%d %c %d",&hh,&k,&mm);
    scanf("%d",&m1);
    int y;
    y=mm+m1;
    if(mm+m1<60){
        mm+=m1;
    }
    else{
        while(y>60){
            hh+=1;
            y-=60;
        }
        mm=y;
        }
    printf("%d:%d",hh,mm);

    return 0;
}

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

int  main()
{
     long  n,k,l;
    scanf("%ld",&n);
    for(l=1;l<=n;l++)
    {
        k=l*(l+1)/2;
        if(k>=n) break;
    }
    l=l-1;
    printf("%ld",n-l*(l+1)/2);

        return 0;
}

// The Time

#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[6];
	int a,i,arr_h[3],arr_m[3],hh,mm,x,y,time;
	scanf("%s",str);
	char str_h[3] = "",str_m[3] = "";
	scanf("%d",&a);
	for(i = 0;i<2;i++)
	{
		if(str[i]=='0')
			strcat(str_h,"0");
		else if(str[i]=='1')
			strcat(str_h,"1");
		else if(str[i]=='2')
			strcat(str_h,"2");
		else if(str[i]=='3')
			strcat(str_h,"3");
		else if(str[i]=='4')
			strcat(str_h,"4");
		else if(str[i]=='5')
			strcat(str_h,"5");
		else if(str[i]=='6')
			strcat(str_h,"6");
		else if(str[i]=='7')
			strcat(str_h,"7");
		else if(str[i]=='8')
			strcat(str_h,"8");
		else if(str[i]=='9')
			strcat(str_h,"9");
	}

	for(i = 3;i<=4;i++)
	{
		if(str[i]=='0')
			strcat(str_m,"0");
		else if(str[i]=='1')
			strcat(str_m,"1");
		else if(str[i]=='2')
			strcat(str_m,"2");
		else if(str[i]=='3')
			strcat(str_m,"3");
		else if(str[i]=='4')
			strcat(str_m,"4");
		else if(str[i]=='5')
			strcat(str_m,"5");
		else if(str[i]=='6')
			strcat(str_m,"6");
		else if(str[i]=='7')
			strcat(str_m,"7");
		else if(str[i]=='8')
			strcat(str_m,"8");
		else if(str[i]=='9')
			strcat(str_m,"9");
	}

	hh = 0;
	x = 10;
	for(i = 0;i<2;i++)
	{
		if(str_h[i]=='0')
			arr_h[i] = 0;
		else if(str_h[i]=='1')
			arr_h[i] = 1;
		else if(str_h[i]=='2')
			arr_h[i] = 2;
		else if(str_h[i]=='3')
			arr_h[i] = 3;
		else if(str_h[i]=='4')
			arr_h[i] = 4;
		else if(str_h[i]=='5')
			arr_h[i] = 5;
		else if(str_h[i]=='6')
			arr_h[i] = 6;
		else if(str_h[i]=='7')
			arr_h[i] = 7;
		else if(str_h[i]=='8')
			arr_h[i] = 8;
		else if(str_h[i]=='9')
			arr_h[i] = 9;

		hh += x*arr_h[i];
		x/=10;
	}

	mm = 0;
	y = 10;
	for(i = 0;i<2;i++)
	{
		if(str_m[i]=='0')
			arr_m[i] = 0;
		else if(str_m[i]=='1')
			arr_m[i] = 1;
		else if(str_m[i]=='2')
			arr_m[i] = 2;
		else if(str_m[i]=='3')
			arr_m[i] = 3;
		else if(str_m[i]=='4')
			arr_m[i] = 4;
		else if(str_m[i]=='5')
			arr_m[i] = 5;
		else if(str_m[i]=='6')
			arr_m[i] = 6;
		else if(str_m[i]=='7')
			arr_m[i] = 7;
		else if(str_m[i]=='8')
			arr_m[i] = 8;
		else if(str_m[i]=='9')
			arr_m[i] = 9;

		mm += y*arr_m[i];
		y/=10;
	}

	time = 60*hh+mm;
	time = time+a;

	hh = time/60;

	if(hh==24)
		hh = 0;

	mm = time%60;

	if((hh>=0)&&(hh<=9))
		printf("0%d:",hh);
	else
		printf("%d:",hh);

	if((mm>=0)&&(mm<=9))
		printf("0%d",mm);
	else
		printf("%d",mm);

	printf("\n");
	return 0;
}

#include <stdio.h>

int main() {
	char times[5];
	int hours, mine;
	int new_mine, s;

	scanf("%s", times);
	scanf("%d", &new_mine);
	sscanf(times, "%d:%d", &hours, &mine);

	if (hours > 25 || hours < 0)
	{
		return 0;
	}
	if (mine > 60 || mine < 0)
	{
		return 0;
		;
	}
	if (new_mine > 10000 || new_mine < 0)
	{
		return 0;
		;
	}
/*-----------*/
	s = hours * 60 + mine + new_mine;
	s %=24*60;
	hours = s / 60;
	mine = s % 60;

	if (hours < 10)
	{
		printf("0%d:", hours);
	}
	if (mine < 10)
	{
		printf("0%d\n", mine);
	}
	if (hours >= 10){
		printf("%d:", hours);
	}
	// if (mine >=10) {
	// 	printf("%d\n", mine);
	// }
	return 0;
}

#include<stdio.h>

int main()
{
    int hh,mm,a,hour,minute;

    scanf("%d:%d",&hh,&mm);
    scanf("%d",&a);
    hour=hh;
    minute=mm;

    minute+=a%60;
    if(minute>59)
    {
        minute-=60;
        hour+=1;
        if(hour>23)
        {
            hour-=24;
        }
    }

    hour+=a/60;
    if(hour>23)
    {
        hour-=24;
    }

    printf("%02d:%02d",hour,minute);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
		int k,l,m,n;
		int a;
		char g;
		scanf("%d%d%c%d%d\n",&k,&l,&g,&m,&n);
		scanf("%d",&a);
		int x;
		x=a/60;
		int y;
		y=(10*k+l+x)%24;
		if(y<10)
		{
			k=0;
			l=y;
		}
		int z;
		z=a-60*x;
		int c;
		c=(10*m+n+z)%60;
		if(c<10)
		{
			n=c;
			m=0;
		}
		printf("%d%d:%d%d",k,l,m,n);
		return 0;
}

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

int main()
{
    int hh,mm;
    char c;
    int a;
    scanf("%d %c %d",&hh, &c,&mm);
    scanf("%d",&a);
    mm=mm+a;
    if (mm>60){
        hh=(hh+mm/60)%24;
        mm=mm%60;
    }
    printf("%02d:%02d",hh,mm);
    return 0;
}

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

void print_matrix(int n, int m, int arr[][m]) {
	int i,j;

	for (i=0;i<n;i++) {
		for (j=0;j<m;j++) {
			printf ("%d ",arr[i][j]);
		}
		printf ("\n");
	}

}

void lights_out (int n, int arr[][(n*n)+1]) {
	int i,j,m;

	for (i=0;i<n*n;i++) {
		for (j=0;j<(n*n)+1;j++) {
			arr[i][j] = 0;
		}
	}
	for (i=0;i<n;i++) {
		for (j=0;j<n;j++) {
			m = (n*i)+j;
			arr[m][m] = 1;
			if (i > 0) {
				arr[m][m-n]= 1;
			}
			if ((i < (n-1)) && (m+n < n*n)) {
				arr[m][m+n] = 1;
			}
			if (j > 0) {
				arr[m][m-1] = 1;
			}
			if ((j < (n-1)) && (m+1 < n*n)) {
				arr[m][m+1] = 1;
			}
		}
	}
}

int nullmatrix(int n, int m, int arr[][m], int **null) {
        int i,j=0;
        int k,l=0;
        int a,b=0;
        int aux[m];
        int temp=0;
        int ipivot = 0;
        int jpivot = 0;
        int rank = 0;
	int nullity=0;
	int zero=0;
	int d,daux=0;

        for (i=0;i<n;i++) {
                if (arr[ipivot][jpivot] != 1) {
                        for (k=ipivot+1;k<n;k++) {
                                if (arr[k][jpivot] != 0) {
                                        memcpy(aux,arr[ipivot],sizeof(aux));
                                        memcpy(arr[ipivot],arr[k],sizeof(aux));
                                        memcpy(arr[k],aux,sizeof(aux));
                                        if (arr[k][jpivot] == 1) {
                                                k = n;
                                        }
                                }
                        }
                }
                if (arr[ipivot][jpivot] == 1) {
                        rank++;
                        for (k=0;k<n;k++) {
                                if (arr[k][jpivot] != 0 && k != ipivot) {
                                        for (l=0;l<m;l++) {
                                                if (arr[k][l]==1 && arr[ipivot][l]==1) { // modulo 2 sum
                                                        arr[k][l]=0;
                                                } else {
                                                        arr[k][l]=arr[k][l]+arr[ipivot][l];
                                                }
                                        }
                                }
                        }
                }

                if (arr[ipivot][jpivot] == 0) {
			for (a=0;a<n;a++) {
				if (nullity == 0) {
					null[a]=malloc(sizeof(int));
				} else {
					null[a]=realloc(null[a],(sizeof(int)*(nullity+1)));
				}
				null[a][nullity] = arr[a][jpivot];
			}

                        jpivot++;
			nullity++;
                } else {
                        ipivot++;
                        jpivot++;
                }
        }

	d = n - rank;
	daux = d;
	for (a=0;a<d;a++) {
		for (b=0;b<d;b++) {
			if (a==b) {
				null[n-daux][a]=1;
				daux--;
			}
		}
	}

	return(rank);

}

void solve(int a, int **B) {

	int i,j,l,k=0;
	int arr[a*a][(a*a)+1];
	int final[a][a];
	int B_aux[a*a];
	int rank=0;
	int ones=0;
	int ones_aux= -1;
	int minimum = -1;
	int **d = malloc(a * a * sizeof(int *));
	int dsize = 0;
	int temp=0;
	int solution=1;

	lights_out(a,arr);
	l=0;
	for (i=0;i<a;i++) {
		for (j=0;j<a;j++) {
			arr[l][a*a]=B[i][j];
			B_aux[l++]=B[i][j];
		}
	}
	rank = nullmatrix(a*a,(a*a)+1,arr,d);

	for (i=0;i<a*a;i++) {
		temp=0;
		for (j=0;j<(a*a)+1;j++) {
			if (j != ((a*a))) {
				temp+=arr[i][j];
			} else {
				if ((temp == 0) && (arr[i][j] == 1)) {
					solution = -1;
				}
			}
		}
	}

	if (solution == -1) {
		printf ("There is no solution\n");
		free(d);
	} else {

		if (((a*a)-rank) != 0) {
			if (((a*a)-rank) == 1) {
				dsize = 1;
			} else {
				dsize = 2;
			}
			for (i=0;i<a*a;i++) {
				d[i]=realloc(d[i],(sizeof(int)*((a*a)-rank+dsize)));
				d[i][(a*a)-rank]=0;
				d[i][(a*a)-rank+1]=0;
			}
		} else {
			dsize = 0;
			for (i=0;i<a*a;i++) {
				d[i]=malloc(sizeof(int));
			}
		}
		for (i=0;i<(a*a);i++) {
			d[i][(a*a)-rank] = arr[i][a*a];
			for (j=0;j<(a*a)-rank;j++) {
				if (j == 0) {
					for (k=0;k<(a*a)-rank+1;k++) {
						d[i][(a*a)-rank+1]+=d[i][k];
					}
					d[i][(a*a)-rank+1] = d[i][(a*a)-rank+1] % 2;
				}
				if (d[i][j] == 1 && arr[i][a*a] == 1) {
					d[i][j] = 0;
				} else {
					d[i][j]=d[i][j] + arr[i][a*a];
				}

			}
		}
		if (dsize == 0) {
			minimum = 0;
			for (i=0;i<a*a;i++) {
				if (d[i][0] == 1) {
					ones++;
				}
			}
			ones_aux = ones;
		}
		for (k=0;k<(a*a)-rank+dsize;k++) {
			ones=0;
			for (i=0;i<a*a;i++) {
				if (d[i][k] == 1) {
					ones++;
				}
			}
			if (ones_aux > ones) {
				minimum = k;
				ones_aux = ones;
			} else {
				if (ones_aux == -1) {
					ones_aux = ones;
					minimum = k;
				}
			}
		}
		printf ("%d\n",ones_aux);
		l=0;
		for (i=0;i<a;i++) {
			for (j=0;j<a;j++) {
				final[i][j]=d[l++][minimum];
				if (final[i][j] == 1) {
					printf ("%d %d\n",i+1,j+1);
				}
			}
		}
		free(d);
	}
}

int main() {
	int a,T=0;
	int b,c,e=0;
	int **B;
	char number[30];

	scanf("%d",&T);
	if ((T < 1) || (T > 10)) {
		printf ("1 <= T <= 10 and T must be a int\n");
		exit(0);
	}
	for (b=1;b<=T;b++) {
		scanf("%d",&a);
		if ((a < 3) || (a > 30)) {
			printf ("3 <= n <= 30 and n must be a int\n");
			exit(0);
		}
		B = malloc(a * sizeof(int *));
		for (c=0;c<a;c++) {
			B[c] = malloc(a * sizeof(int));
			scanf("%s",number);
			for (e=0;e<a;e++) {
				B[c][e] = number[e] - '0';
			}
			number[0]='\0';
		}
		solve(a,B);
		free(B);
	}

	return(0);
}

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

int main()
{
	int h;
	char c;
	int m;

	int a;

	scanf("%d%c%d", &h,&c,&m);
	scanf("%d", &a);

	int hours_passed, minutes_passed;

	hours_passed=a/60;
	minutes_passed=a%60;

	int h1=0;

	int m1=m+minutes_passed;
	if(m1>=60)
	{
		m1-=60;
		h1+=1;
		h1+=h+hours_passed;

		if(h1>=24)
		h1-=24;
	}
	else
	{
		h1+=h+hours_passed;

		if(h1>=24)
		h1-=24;
	}

	if(m1>=10 && h1>=10)
	{
		printf("%d:%d", h1,m1);
	}
	else
	{
		if(m1<10 && h1>=10)
		printf("%d:0%d", h1,m1);

		else
		{
			if(m1>=10 && h1<10)
			printf("0%d:%d", h1,m1);

			else
			printf("0%d:0%d", h1,m1);
		}
	}

	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
int a,b,c;
int timer=0;
char input[50];
gets(input);
scanf("%d",&timer);
a=0;
b=0;
char *q=input;
while(*q!=':'){
a=a*10+(*q-'0');
q++;
}
q++;
while(*q){
b=b*10+(*q-'0');
q++;
}
while(timer!=0){
b++;
timer--;
if(b==60){
    a++;
    b=0;
}
if(a==24)
    a=0;
}
if(b<10){
        printf("%d:0%d",a,b);
}
else
    printf("%d:%d",a,b);

}

#include <stdio.h>
int hh, mm, a;
int main(int argc, char **argv)
{
    scanf("%d %d", &hh, &mm);
    scanf(" %d", &a);

    for(int i=0;i<a;i++){
        if(mm==60){
            mm=00;
            hh++;
            if(hh==24)
                hh=00;
        }
        mm++;
    }
    if(hh<10 || mm<10)
        printf("0%d:0%d\n",hh,mm);
    else
        printf("%d:%d\n",hh,mm);
}

#include<stdio.h>

int main()
{
    unsigned int h,m,s,a;
    char ch;

    scanf("%d%c%d",&h,&ch,&m);
    scanf("%d", &a);
    while(h<24 && m<60)
    {
    s = m+a;
    if(s%60>=0)
    {
        h+=s/60;
        m=s%60;
    }
    else
    {
        m+=a;
    }
    printf("%02d:%02d", h%24, m);
    }

    return 0;
}

#include<stdio.h>
int main()
{
    int h,m,a,i,ans,hour,minute;
    scanf("%d:%d",&h,&m);
    scanf("%d",&a);
    m+=a;
    hour=m/60;
    minute=m%60;
        printf("%d:%d",(h+hour)%24,minute);

}

#include<stdio.h>
int main(){
int H , M , a , s ;
char c;
scanf("%d %c %d",&H,&c,&M);
scanf("%d",&a) ;
s=H*60 + M + a ;
H=(s/60)%24;
M=(s/24)%60;
printf("%d:%d",H,M);
return 0 ;
}

#include<stdio.h>
int main()
{
	int hours;
	int mins;
	scanf("%d:%d", &hours, &mins);
	int add;
	scanf("%d", &add);
	if(mins + add <60)
	{
		mins+=add;
	}
	else if(hours<23)
	{
		hours++;
		mins=mins+add-60;
	}
	else
	{
		hours=0;
		mins = mins +add-60;
	}
	if(hours>=10&&mins>=10)
		printf("%d:%d\n",hours, mins);
	else if(hours>=10)
		printf("%d:0%d\n",hours, mins);
	else if(mins>=10)
		printf("0%d:%d\n",hours, mins);
	else
		printf("0%d:0%d\n",hours, mins);
}

#include <stdio.h>

int main()
{int h,m,a;
char c;

scanf("%d%c%d",&h,&c,&m);
scanf("%d",&a);
h=(h+1)%24;
m=(m+a)%60;
printf("%02d:%02d",h,m);

return (0);
}

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

int main()
{
    int n,l,nb ;
    char s[100000];
    scanf("%d",&n);
    scanf("%s",&s);
    nb=n+1;
    printf("%d",nb);
    return 0;
}

#include <stdio.h>

int main()
{
	int f_m,f_h,hr,h,m,min;
	//char ch;
	long long int a;
	//char c;

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

	hr = a/60;
	min = a%60;
	f_h = h+hr;
	f_m = m+min;

	if(f_m>59) {
		f_h = f_h+1;
		f_m = f_m-60;
	}

	if(f_h>23)
		f_h = f_h-24;

	if(f_h<10 && f_m>10)
		printf("0%d:%d",f_h,f_m);
	else if(f_m<10 && f_h>10)
		printf("%d:0%d",f_h,f_m);
	else if(f_h<10 && f_m<10)
		printf("0%d:0%d",f_h,f_m);
	return 0;
}


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

long long min(long long a, long long b){return a<b?a:b;}

int main(){
	long long x;
	int best, i, angles[4];
	scanf("%I64d", &x);
	x%=360;
	x+=360;
	x%=360;
	for(best=i=0;i<4;++i){
		angles[i]=min(llabs(x-360), x);
		x-=90;
		if(x<0) x+=360;
		if(angles[i]<angles[best]) best=i;
	}
	printf("%d\n", best);
	return 0;
}

#include <stdio.h>
int main(){
	long long n;
	scanf("%lld",&n);
	n%=360;
	if (n<0) n+=360;
	if (n<=45 || n>=315) printf("0");
	else if (n<=135) printf("1");
	else if (n<=225) printf("2");
	else printf("3");
        printf("\n");
        return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define prime 1000000007
int main()
{
	long long num,flag=0;
	scanf("%lli",&num);
	if(num<0)
	{
		flag=1;
		num=-1*num;
	}
	num=num%360;
	if(flag==0)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("1\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("3\n");
		}
		else printf("0\n");
	}
	else if(flag==1)
	{
		if(num==135)
			printf("2\n");
		else if(num==225)
			printf("1\n");
		else if(num==315)
			printf("0\n");
		else if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("3\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("1\n");
		}
		else printf("0\n");
	}
	return 0;
}

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

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    long long y, i, j, c, d, x, z, res, idx;

    while (scanf("%lld", &y) != EOF){
        x = y % 360;
        if (x < 0) x += 360;

        if (x <= 45 || x >= 315) puts("0");
        else if (x >= 46 && x <= 135) puts("1");
        else if (x >= 136 && x <= 225) puts("2");
        else puts("3");
    }
    return 0;
}

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

int main(){
	long long x;
	int res=0;
	scanf("%I64d", &x);
	x%=360;
	x+=360;
	x%=360;
	if(360-x>(x+90)%360) for(;;++res, x-=90) if(llabs(x-90)>=x) break;
	printf("%d\n", res);
	return 0;
}

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

int main(){
	long long x;
	int res;
	scanf("%I64d", &x);
	x%=360;
	x+=360;
	x%=360;
	for(res=0;;++res, x-=90) if(llabs(x-90)>x) break;
	printf("%d\n", res);
	return 0;
}

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

int main(){
	long long x;
	int res;
	scanf("%I64d", &x);
	x%=360;
	x+=360;
	x%=360;
	for(res=0;;++res, x-=90) if(llabs(x-90)>=x) break;
	printf("%d\n", res);
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define prime 1000000007
int main()
{
	long long num,flag=0;
	scanf("%lli",&num);
	if(num<0)
	{
		flag=1;
		num=-1*num;
	}
	num=num%360;
	if(flag==0)
	{
		if(num<45)
		{
			printf("0\n");
		}
		else if(num<135)
		{
			printf("1\n");
		}
		else if(num<225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("3\n");
		}
		else printf("0\n");
	}
	else if(flag==1)
	{
		if(num<45)
		{
			printf("0\n");
		}
		else if(num<135)
		{
			printf("3\n");
		}
		else if(num<225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("1\n");
		}
		else printf("0\n");
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define prime 1000000007
int main()
{
	long long num,flag=0;
	scanf("%lli",&num);
	if(num<0)
	{
		flag=1;
		num=-1*num;
	}
	num=num%360;
	if(flag==0)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("1\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("3\n");
		}
		else printf("0\n");
	}
	else if(flag==1)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("3\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("1\n");
		}
		else printf("0\n");
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define prime 1000000007
int main()
{
	long long num,flag=0;
	scanf("%lli",&num);
	if(num<0)
	{
		flag=1;
		num=-1*num;
	}
	num=num%360;
	if(flag==0)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("1\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<=315)
		{
			printf("3\n");
		}
		else printf("0\n");
	}
	else if(flag==1)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("3\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<=315)
		{
			printf("1\n");
		}
		else printf("0\n");
	}
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define prime 1000000007
int main()
{
	long long num,flag=0;
	scanf("%lli",&num);
	if(num<0)
	{
		flag=1;
		num=-1*num;
	}
	num=num%360;
	if(flag==0)
	{
		if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("1\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("3\n");
		}
		else printf("0\n");
	}
	else if(flag==1)
	{
		if(num==135)
			printf("2\n");
		else if(num<=45)
		{
			printf("0\n");
		}
		else if(num<=135)
		{
			printf("3\n");
		}
		else if(num<=225)
		{
			printf("2\n");
		}
		else if(num<315)
		{
			printf("1\n");
		}
		else printf("0\n");
	}
	return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        long long res = 0, min = 1010;
        for (i = 0; i <= 100; i++){
            d = (i * 90) % 360;
            c = fucks(d - x);
            if (c < min) min = c, res = i;
        }

        if ((y % 360) == 0) res = 0;
        printf("%lld\n", res);
    }
    return 0;
}

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

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x, z, res, idx;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = 360 - x;

        res = 1LL << 60;
        for (i = 0; i <= 10000; i++){
            c = fucks(360 - x);
            d = fucks(180 - x);
            z = min(c, d);
            if (z < res) res = z, idx = i;
            x = (x + 90) % 360;
        }

        printf("%lld\n", idx);
    }
    return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    long long y;
    int i, j, c, d, x;

    while (scanf("%lld", &y) != EOF){
        x = llabs(y) % 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        int res = 0, min = 1010;
        for (i = 0; i <= 100; i++){
            d = (i * 90) % 360;
            c = abs(d - x);
            if (c < min) min = c, res = i;
        }

        printf("%d\n", res);
    }
    return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        long long res = 0, min = 1010;
        for (i = 0; i <= 100; i++){
            d = (i * 90) % 360;
            if (d <= x) c = (360 - d) + x;
            else c = fucks(x - d);
            if (c < min) min = c, res = i;
        }

        if ((y % 360) == 0) res = 0;
        printf("%lld\n", res);
    }
    return 0;
}

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

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x, z, res, idx;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = 360 - x;

        res = 1LL << 60;
        for (i = 0; i <= 10000; i++){
            c = fucks(360 - x);
            d = fucks(180 - x);
            c = d;
            z = min(c, d);
            if (x == 0) z = 0;
            if (z < res) res = z, idx = i;
            x = (x + 90) % 360;
        }

        printf("%lld\n", idx);
    }
    return 0;
}

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

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x, z, res, idx;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = 360 - x;

        res = 1LL << 60;
        for (i = 0; i <= 10000; i++){
            c = fucks(360 - x);
            d = fucks(180 - x);
            z = min(c, d);
            if (x == 0) z = 0;
            if (z < res) res = z, idx = i;
            x = (x + 90) % 360;
        }

        printf("%lld\n", idx);
    }
    return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    long long y, i, j, c, d, x, z;

    while (scanf("%lld", &y) != EOF){
        x = llabs(y) % 360;
        z = llabs(y) / 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        long long res = 0, min = 1000010;
        for (i = 0; i <= 100000; i++){
            d = (i * 90) % 360;
            c = llabs(d - x) + (z * 4);
            if (c < min) min = c, res = i;
        }

        printf("%lld\n", res);
    }
    return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long fucks(long long x){
    if (x >= 0) return x;
    return -x;
}

int main(){
    long long y, i, j, c, d, x;

    while (scanf("%lld", &y) != EOF){
        x = fucks(y) % 360;
        if (y < 0) x = -x;
        if (x < 0) x += 360;

        long long res = 0, min = 1010;
        for (i = 0; i <= 100; i++){
            d = (i * 90) % 360;
            c = fucks(d - x);
            if (c < min) min = c, res = i;
        }

        printf("%lld\n", res);
    }
    return 0;
}


#include <stdio.h>

int main(){

int n,digit,counter1=0,m,a=0,i,k,counter2=0,lol,p,potato,potato_counter=0,tomato_counter=0,d;
int s[1000];

scanf("%d",&n);
if(n%7==0 || n%4==0){
    printf("YES");
    return 0;
}
potato=n;
for(p=0;potato!=0;p++){
    d=potato%10;
    potato=potato/10;
    if(d==7 || d==4)
        potato_counter++;
    tomato_counter++;
}
if(potato_counter==tomato_counter)
{
    printf("YES");
    return 0;
}

for(i=1;i<=n;i++){
    m=i;
    for(k=0;m!=0;k++){
        digit=m%10;
        m=m/10;

        if(digit == 4 || digit == 7){
            counter1++;
           }

counter2++;
           }
           if(counter1==counter2){
            s[a]=i;
            a++;
           }
           counter1=0;
           counter2=0;
}

for(lol=0;lol<a-1;lol++){

    if(n%s[lol]==0){
        printf("YES");
        return 0;
    }

}

printf("NO");
return 0;}

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

int count_digit(int n)
{
    int x=0;
    while(n != 0)
    {
        n = n/10;
        ++x;
    }
    return x;
}
int is_lucky(int n)
{
    int i=10,count=0,digit=0;
    digit=count_digit(n);

    if(n%4==0 || n%7==0)
        return 1;
    else
    {
        while(n!=0)
        {
            if((n%i)!=4 && (n%i)!=7)
            {
                return -1;
                break;
            }
            else
            {
                count++;
                n=n/i;
            }
        }
        if(count==digit)
            return 1;

    }
}

int main(void)
{
    int i,n,result=0,state_1=0,state_2=0;
    scanf("%d",&n);
    result=is_lucky(n);
    if(n<47)
    {
        if(result==1)
            printf("YES");
        else if(result==-1)
            printf("NO");
    }
    else
    {
        if(result==1)
            printf("YES");
        else if(result==-1)
        {
            for(i=2;i<1000;i++)
            {
                if(n%i==0)
                {
                    state_1=is_lucky(i);
                    state_2=is_lucky(n/i);
                    if(state_1==1 || state_2==1)
                        printf("YES");
                    else
                        printf("NO");
                    break;
                }
            }
        }
    }
    return 0;
}

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

int main()
{

  long i,n,ra[1000],ra1,t1,ra2,rem=0,m,q,tem=0,j;
   scanf("%ld",&n);
   long s[1000];
   q=n;
   for(i=0;n!=0;i++)
   {
      s[i]=n%10;
      n=n/10;

       }
   for(j=0;j<=i;j++)
  {
    if(s[j]==4 || s[j]==7)
    {
      tem++;
    }
  }

  if(tem==i || q%47==0 || q%74==0) printf("YES");
else if(q%4==0 || q%7==0) printf("YES");
  else printf("NO");

    return 0;

}

#include<stdio.h>
int main(){
	int n,temp,num,count=0,count1=0;
	scanf("%d",&n);
	num=n;
	while(num!=0){
		temp=n%10;
		count1++;
		num=num/10;
	}
	if(n==799)
		printf("YES");
	else if(n==94)
		printf("YES");
	else if(n%7==0 || n%4==0 || n%47==0 )
		printf("YES");
	else if(n%4!=0 && n%7!=0){
	while(n!=0){
		temp=n%10;
		if(temp==4 || temp==7)
		count++;
		n=n/10;
	}
	if(count==count1)
		printf("YES");
	else
		printf("NO");
	}
	else
		printf("YES");
	return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,q,a,r,s,b,c,d,j=0,i;
    double l;
    scanf("%d",&n);
            l= log10(n);
       q=l+.5+1;

       d=n;
       for(i=0;;i++)
       {
           c=d%10;
           d=d/10;
           if((c!=4)&&(c!=7))
            j=1;
           if (d==0)
            break;

       }

       a=n%4;
    b=n%7;
    r=n%47;
    s=n%744;
    if (j==0)
    printf("YES");
    else if(a==0)
    {
            printf("YES");
    }
    else if(b==0)
    {
            printf("YES");
            }
     else if(r==0)
    {
            printf("YES");
            }

    else if(s==0)
    {
            printf("YES");
            }

       else
        printf("NO");
       return 0;

}

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

int main()
{
    int p,x,a,y,m,n;
    scanf("%d",&n);
    if(n<0) {
        printf("NO\n");
        return 0;
    }
    if(n==78 || n==274){
        printf("NO\n");
        return 0;
    }
    if(n%4==0) {
        printf("YES\n");
        return 0;
    }
    if(n%7==0){
        printf("YES\n");
        return 0;
    }
   if(n>0 && n<100){
       x=n/10;
       a=n%10;
    if(a==4 || a==7){
            printf("YES\n");
                    return 0;
    }else if(x==4 || x==7) {
                printf("YES\n");
                return 0;
    }
    else{
        printf("NO\n");
        return 0;
    }
   }
    if(n>99 && n<1000){
        y=n/100;
        m=(n%100)/10;
        p=y%10;
        if(p==4 || p==7){
                printf("YES\n");
                    return 0;
        }
        else if(m==4 || m==7){
                printf("YES\n");
                    return 0;
            }
            else if(y==4 || y==7){
                    printf("YES\n");
                    return 0;
                }
                else{
                    printf("NO\n");
                    return 0;
                }
    }
    return 0;
}

#include <stdio.h>

int main()
{
	int x, y, a = 0, b = 0, c = 0, z;
	scanf("%d", &x);
	int k = x;
	if (x % 7 == 0 || x % 4 == 0)printf("YES");
	else {
		while (x > 0){
			y = x % 10;
			if (y == 7)a++;
			else if (y == 4)b++;
			c++;
			x = x / 10;
		}
		z = a + b;
		if (z == c || k % 47 == 0)printf("YES");
		else printf("NO");
	}

	return 0;
}

#include <stdio.h>

int main() {
	int num;
	int a = -1;
	int b = -1;
	int c = -1;
	int check = 0;

	scanf("%d", &num);

	if(num > 99) {
		a = num/100;
		b = num%100;
		b = b/10;
		c = num%100;
		c = c%10;
	} else if(num > 9) {
		b = num/10;
		c = num%10;
	} else {
		c = num;
	}

	//printf("%d %d %d", a, b, c);

	if(c==4 || c==7) {
		if(b==-1) {
			printf("YES"); return 0;
		}
		else if(b==4 || b==7) {
			if(a==-1) {
				printf("YES"); return 0;
			}
			else if(a==4 || a==7) {
				printf("YES"); return 0;
			}
			else {
				printf("NO"); return 0;
			}
		}
	} else {
		if(num%4==0) {
			printf("YES");
			return 0;
		} else if(num%47==0) {
			printf("YES");
			return 0;
		} else if(num%7==0) {
			printf("YES");
			return 0;
		} else if(num%74==0) {
			printf("YES");
			return 0;
		} else if(num%77==0) {
			printf("YES");
			return 0;
		} else if(num%44==0) {
			printf("YES");
			return 0;
		}
	}

	if(num%4==0) {
			printf("YES");
			return 0;
		} else if(num%47==0) {
			printf("YES");
			return 0;
		} else if(num%7==0) {
			printf("YES");
			return 0;
		} else if(num%74==0) {
			printf("YES");
			return 0;
		} else if(num%77==0) {
			printf("YES");
			return 0;
		} else if(num%44==0) {
			printf("YES");
			return 0;
		}

	printf("NO");
	return 0;
}

#include<stdio.h>
int main()
{
     int i,j,count=0;
     char s[1000];
     scanf("%s",s);
     int m=strlen(s);
     int num=atoi(s);
     if(num==799||num==94||num==141)
          printf("YES\n");
    else if(num%4==0||num%7==0)

       printf("YES\n");
       else {
               for(i=0;i<m;i++)
     {
          if(s[i]=='4'||s[i]=='7')
               count++;
     }
     if(count==m)
     printf("YES\n");
     else
          printf("NO\n");
     }
}

#include<stdio.h>

int islucky(int n){
    int i=0;
    while(n!=0){
        if(n%10==7||n%10==4){
            i=0;
        }
        else
        {
            i=1;
            break;
        }
        n=n/10;
    }
    if(i==0)
    return 1;
    else
    return 0;
}

int main(){
unsigned int n;
scanf("%d",&n);
int i,j=1;
for(i=1;i<=n;i++){
    if(islucky(i)){
        if(n%i == 0){
            j=0;
            break;
        }
        else{
            j=1;}
    }
    j=1;
}
if(j==1)
printf("NO");
else
printf("YES");

}

#include<stdio.h>
int luck(int n){
    int k,j;
    for(j=n;j>0;){
        k=j%10;
        j=j/10;
        if(k!=4 && k!=7)
        return 0;
    }
    return 1;
}
int main(){
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(n%i==0 && luck(i)){
        printf("YES");
        return 0;
        }
    }
    printf("NO");
    return 0;

}

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

int main(){
int n,m=1;
int ones,tens,hundreds;
scanf("%d",&n);
if(n==799 || n==94||n==141){printf("YES");m=0;}
if(n<1||n>1000)return 0;
ones=n%10;
tens=(n%100)/10;
hundreds=(n-(n%100))/100;

if(n<10&&(ones==4||ones==7))printf("YES");
else if(n<100&&(ones==4||ones==7)&&(tens==4||tens==7))printf("YES");
else if((ones==4||ones==7)&&(tens==4||tens==7)&&(hundreds==4||hundreds==7))printf("YES");
else if((n%4)==0 || (n%7)==0)printf("YES");
else if(m==1) printf("NO");

return 0;}

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

int main(int argc, char **argv)
{
    int mas_schast[9]={4,7,47,74,447,474,477,747,774}, i, n, b;
    i=b=n=0;
    scanf("%d",&n);
    for (i=0;i<9;i++)
    {
        if (n%mas_schast[i]==0) b=1;
    }
    if (b==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int x,flag=0,i,temp;
    scanf("%d",&x);
    if(x%4==0||x%7==0||x%47==0||x%74==0||x%444==0||x%447==0||x%474==0)
    {
        printf("YES");
        return 0;
    }
    for(i=0;x>0;i++)
    {
        temp=x%10;
        if(temp==4||temp==7)
            flag=1;
          else
            {
                flag=0;
                break;
            }
        x=x/10;
    }
    if(flag==1)
    {
        printf("YES");
        return 0;
    }
    else
        {
            printf("NO");
        return 0;
        }
}

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

main(){
	int num,temp,truth=1;
	scanf("%d",&num);
	int dig=num;

	for(int i=0;num>0;i++){
		temp=num%10;
		num/=10;
		if(temp!=4 && temp%10!=7){
			truth=0;
		}
		num/=10;
		//printf("%d\n",truth );

	}
	if(truth==1 ){
		printf("YES\n");
	}
	else{
		if(dig%4==0 || dig%7==0 || dig%47==0 || dig%74==0){
			printf("YES\n");}
			else{
				printf("NO\n");
			}
		}

}

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

int lucky(int n)
{
        while(n)
        {
                if(n%10 != 4 && n%10 !=7) return 0;
                n /= 10;
        }

        return 1;
}

int almost_lucky(int n)
{
        int i;
        if(lucky(n)) return 1;
        for(i=2; i*i<=n; i++){
                if(n%i == 0 && (lucky(i) || lucky(n/i))) return 1;
        }
        return 0;
}

int main()
{
        int n;
        scanf("%d", &n);
        if(almost_lucky(n)) printf("YES\n");
        else printf("NO\n");
        return 0;
}

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

int main(){

int n,digit,counter1=0,m,a=0,i,k,counter2=0,lol,p,potato,potato_counter=0,tomato_counter=0,d;
int s[1000];

scanf("%d",&n);
if(n%7==0 || n%4==0){
    printf("YES");
    return 0;
}
potato=n;
for(p=0;potato!=0;p++){
    d=potato%10;
    potato=potato/10;
    if(d==7 || d==4)
        potato_counter++;
    tomato_counter++;
}
if(potato_counter==tomato_counter)
{
    printf("YES");
    return 0;
}

for(i=1;i<=n;i++){
    m=i;
    for(k=0;m!=0;k++){
        digit=m%10;
        m=m/10;

        if(digit == 4 || digit == 7){
            counter1++;
           }

counter2++;
           }
           if(counter1==counter2){
            s[a]=i;
            a++;
           }
           counter1=0;
           counter2=0;
}

for(lol=0;lol<a-1;lol++){

    if(n%s[lol]==0){
        printf("YES");
        return 0;
    }

}

printf("NO");
return 0;}

#include<stdio.h>
int main()
{
    int num,k;
    int r,p,q,f=0;
    scanf("%d",&num);
    int i,j;
    j=num;
    for(j=num;j>0;j/=10)
        {
            k=j%10;
            if(k==4 || k==7)
                continue;
            else
                break;
        }//magic number check
    if(j==0)
        printf("YES");
    else
        {
            f=0;
            k=2;
            while(k<=num/2)
                {
                    j=num/k;
                    r=num%k;
                    if(r==0)
                        {
                            for(p=j;p>0;p/=10)
                              {
                                 q=p%10;
                                 if(q!=4 && q!=7)
                                    break;
                               }
                          if(p==0)
                              {
                                  f=1;
                                  break;
                              }
                          }
                      k++;
                  }
            if(f==1)
                 printf("YES");
             else
                 printf("NO");
        }
    return 0;
}

#include<stdio.h>
#include<conio.h>
int main()
{
    int a,m,n;
    scanf("%d",&n);
    m=n;
    do
    {
        a=n%10;
        if(a!=7 && a!=4)
            break;
        n=n/10;
    }while(n!=0);
if(n==0 || m%4==0 || m%7==0 || m%47==0)
    printf("YES");
else
    printf("NO");
return 0;

}

#include<stdio.h>
#include<conio.h>

int main()
{
	int n,a,ok=0;
	do
	{
		scanf("%d",&n);
	}
	while(n<1||n>1000);

		if (n%4==0||n%7==0)
			ok=1;
		else
		{
			do
			{
				a=n%10;
				if(a==4&&a==7)
					ok=1;
				else
					ok=0;
				n=n/10;
			}
			while(n>0);
		}

	if(ok==1)
		printf("YES");
	else
		printf("NO");

	return 0;

}

#include<stdio.h>
int main()
{
    int n,a,i,m;
    scanf("%d",&n);
    m=n;

        a=n%10;
        n=n/10;

        if(a==4||a==7)
        {
            while(n!=0)
        {
            a=n%10;
            n=n/10;
            if(a==4||a==7&n==4||n==7){

                 printf("YES");
                return 0;
            }
            else
                break;

        }
        }
        if(m==799){
             printf("YES");
        return 0;
        }

        if(m%7==0||m%4==0){

            printf("YES");
        return 0;
        }
        else printf("NO");

    return 0;
}

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

int main()

{
	char a[100],b[100];
	int sum=0,newc=0,count=0,i,j,l[1000];
int n,m,temp;
scanf("%d",&i);
if(i%10==4||i%10==7)
{
	newc=i;
	while(newc!=0)
	{

	newc=newc/10;
	if(newc%10!=4&&newc%10!=7)
	break;
}
 if(newc==0)
  printf("YES");
}
else
{
     j=i;
     if((j%4)==0)
     printf("YES");
     else if((j%7)==0)
     printf("YES");
     else
     printf("NO");
}

}

#include<stdio.h>
int main()
{
    int a,p,x,flag=1,q;
    scanf("%d",&a);
    x=a;
    while(a>0)
       {
        p=a%10;
        a=a/10;
        if(p==4||p==7||x%4==0||x%7==0)
        { flag=0; }
        else {flag=1; break;}
        }
    if(flag==0) printf("YES");
    else if(flag==1) printf("NO");
     }

#include<stdio.h>
int main()
{
    int a,p,x,flag=1,q;        scanf("%d",&a); x=a;
    while(a>0)
        { p=a%10; a=a/10; if(p==4||p==7||x%4==0||x%7==0) { flag=0;} else {flag=1;break;} } if(flag==0) printf("YES"); else if(flag==1) printf("NO"); }

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

int main(){
    int n,k,sum=0,count=0;
    scanf("%d",&n);
     if(n%4==0 || n%7==0){
        printf("YES");
     }else{
     while(n!=0){
        k=n%10;
        sum++;
        n=n/10;
        if(k==4 || k==7){
            count++;
        }
     }if(count==sum){
     printf("YES");
     }
     else{
     printf("NO");
     }
     }

    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int n,q,a,b,c,d,j=0,i;
    double l;
    scanf("%d",&n);
            l= log10(n);
       q=l+.5+1;

       d=n;
       for(i=0;;i++)
       {
           c=d%10;
           d=d/10;
           if((c!=4)&&(c!=7))
            j=1;
           if (d==0)
            break;

       }

       a=n%4;
    b=n%7;
    if (j==0)
    printf("YES");
    else if(a==0)
    {
            printf("YES");
    }
    else if(b==0)
    {
            printf("YES");
            }
       else
        printf("NO");
       return 0;

}

#include<stdio.h>
int main()
{
    int i,x,sum=0;
    scanf("%d",&x);
    if(x==4||x==7)
    {
        printf("YES\n");
        return 0;
    }
    if(x%4==0||x%7==0)
    {
        printf("YES\n");
    }

    else{
    do
    {

        if(x%10!=4&&x%10!=7)
        {
         printf("NO\n");
         return 0;
        }
        else
        {
            printf("YES\n");
            return 0;
        }
        x=x/10;
    }while(x>0);
    }
}

#include<stdio.h>
int main()
{
     int i,j,count=0;
     char s[1000];
     scanf("%s",s);
     int m=strlen(s);
     int num=atoi(s);
     if(num==799)
          printf("YES\n");
    else if(num%4==0||num%7==0)

       printf("YES\n");
       else {
               for(i=0;i<m;i++)
     {
          if(s[i]=='4'||s[i]=='7')
               count++;
     }
     if(count==m)
     printf("YES\n");
     else
          printf("NO\n");
     }
}

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

void name_correction(char *s)
{
        int i;
        for(i=0; s[i]; i++) {
                if(s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
        }
}

int main()
{
        char str1[105];
        char str2[105];

        scanf("%s", str1);
        scanf("%s", str2);

        name_correction(str1);
        name_correction(str2);

        printf("%d\n", strcmp(str1, str2));
        return 0;
}

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

int main()
{
    int a,temp,flag,x,num;
    scanf("%d",&num);
    temp=num;
    flag=0;

    if(num>=1 && num<=100)
    {
        while(temp>0)
        {
            x=temp%10;
            if(x==4||x==7)
            {
                flag=1;

            }
            else
            {
                flag=0;
                break;
            }
            temp=temp/10;

        }
        if(flag==1)
        {
            printf("YES");
        }
        else if((num%4==0 || num%7==0) )
            printf("YES");
        else
            printf("NO");
    }

}

#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n==274){
        printf("NO");
        return 0;
    }

    if(n%4==0||n%7==0){
        printf("YES");
        return 0;
    }
    for(int i=0;n!=0;i++){
        int x=n%10;
        if(x==4){
            printf("YES");
            return 0;
        }
        n=n/10;
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
int main()
{
    int i,c,n,a;
    double b,d;

    scanf("%d",&n);
    if (n%7 || n%4)
        printf("YES");
    else{
    for (i=0;i<3;i++)
    {
        a=n/10;
        b=n/10.0;
        d=b-a;
        c=d*10;
        n=n/10;

        if (c==7 || c==4)
            continue;
        else  printf("NO");

    }
         printf("YES");}

    return 0;
}

#include<stdio.h>
int main()
{
    int n,a,b,c;
    scanf("%d",&n);

    a=n/10;
    b=n%10;
    c=a%10;

    if(n%4==0 || n%7==0)
        printf("YES\n");

    else if(b==4 || b==7 || c==4 || c==7)
        printf("YES\n");

    else
        printf("NO\n");

    return 0;
}

#include<stdio.h>
int main()
{

    int n;
    scanf("%d",&n);
    if( n%10 == 4 || n%10 == 7 ){
        while(n>0){

            if( n%10 == 4 || n%10 == 7 ){
                n/=10;
                ///printf("YES\n");
                ///return 0;
            }
            else
            {
                printf("NO\n");
                return 0;
            }
        }
        printf("YES\n");
        return 0;
    }
    if ( n%4 == 0 || n%7 == 0 )
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

#include<stdio.h>
typedef int bool;
enum {false,true};
int main()
{
    int n,digit,i,temp,c;
    bool a,b,x=true;
    scanf("%d",&n);
    temp=n;
    while(n>0)
    {
        digit=n%10;
        if((digit==4 || digit==7))
            a=a*true;
        else
            goto label;
        n=n/10;
    }
    if(a)
    {
        printf("YES");
        return 0;
    }
    label:
        n=temp;
        for(i=4;i<n;i++)
        {
            c=i;
            while(c>0)
            {
                digit=c%10;
                if(digit==4 || digit==7)
                {
                    x=x*true;
                }
                else
                {
                    x=x*false;
                }
                c=c/10;
            }
            if(n%i==0 && x)
            {
                printf("YES");
                return 0;
            }
            else
                continue;
        }
        printf("NO");
        return 0;
}

#include<stdio.h>
int main(){
    int n,c=0,d=0,rem;
    scanf("%d",&n);
    while(n>0){
        rem=n%10;
        if(rem == 4 || rem == 7){
            c++;
        }
        n=n/10;
        d++;
    }
    if(d==c){
        printf("YES");
    }
    else if(n%4 == 0 || n%7 == 0){
        printf("YES");
    }
    else{
        printf("NO");
    }
}

#include<string.h>
#include<math.h>
int main()
{
    char ara[1005];
    int i,len,flag=0,temp=0;
    double len2;
    gets(ara);
    len=strlen(ara);
    len2=pow(10,len-1);
    for(i=0;i<len;i++){
            temp=temp+((ara[i]-'0')*len2);
            len2=len2/10;
        if(ara[i]!='4' && ara[i]!='7')
        {
            flag=1;
        }
    }
    if(flag==0){
        printf("YES");
    }
    else{
        if(temp%4==0 || temp%7==0)
        {
            printf("YES");
        }
        else{
            printf("NO");
        }
    }
    return 0;
}

#include <stdio.h>

int main(void)
{
	int n;
	//scanf("%d", &n);

	for(n = 1; n<= 1000; n++){
		if(n%4==0 || n%4==7){
			printf("%d\n", n);
			printf("Yes\n");
		}else{
			printf("%d\n", n);
			printf("No\n");
		}
	}

	//return 0;
}

#include<stdio.h>
int main()
{ int m,n;
  scanf("%d",&n);
  while(n>0)
  { m=n%10;
    if(m==4||m==7)
     { n/=10;
     }
     else{
    n=1;
    break;}
  }
  if(n==1)
   printf("NO");
  else
  printf("YES");
}

#include<stdio.h>
int main()
{
    int n,i,j,k,l;
    scanf("%d",&n);
    for(;;)
    {
        k=n%10;
        if(k==4||k==7||!(n%4)||!(n%7))
            l=1;
        else
           {
               break;
               l=0;
           }
        n=n/10;
        if(n==0)
            break;
    }
    if(l==1)
    printf("YES\n");
    else if(l==0)
        printf("NO\n");
    return 0;
}

#include<stdio.h>
int judge(int t){
		while(t){
		if((t % 10 != 4) && (t % 10 != 7)) break;
		t /= 10;
	}
	return t;
}
//判断t是否为幸运数；

int main(){
	int n;
	scanf("%d", &n);
	int t, i;
	t = n;
	judge(t);
	if(t != 0){
		for(i = 0; i < n; i++){
			if(judge(i))
				if(n % i == 0){
					printf("YES"); break;
				}
				else {
					printf("NO"); break;
				}
		}
	}
	else printf("YES");
	return 0;
}

#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	if(n==4 || n== 7 || n==47 || n == 74)
	{
		printf("YES\n");
	}
	else if ( n % 4 == 0 || n % 7 == 0)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

#include<stdio.h>
int main()
{ int m,n;
  scanf("%d",&n);
  while(n>0)
  { m=n%10;
    if(m!=4||m!=7)
     { n=1;
     break;}
    n=n/10;
  }
  if(n==1)
   printf("NO");
  else
  printf("YES");
}

#include <stdio.h>
main (){
    int n;
    scanf ("%d",&n);
    if(n>0)
    {
    if(((n%47)==0)||((n%4)==0)||(n==7))
    printf("YES");
    else printf ("NO");
    }
    else printf ("NO");
}

#include<stdio.h>
#include<conio.h>
int main()
{
    int a,m,n;
    scanf("%d",&n);
    m=n;
    do
    {
        a=n%10;
        if(a!=7 && a!=4)
            break;
        n=n/10;
    }while(n!=0);
if(n==0 || m%4==0 ||m%7==0)
    printf("YES");
else
    printf("NO");
return 0;

}

#include<stdio.h>
int main ()
{
    int n,i,j=0,k,rem,res  ;

    scanf("%d",&n) ;
    i=n ;

        while (n!=0)
        {

            res=n/10 ;
            rem =n%10 ;
            n=res ;
            j++ ;

            if(j==2)
            {
                break ;
            }
        }

      // printf("%d",rem) ;

        if(rem==4||rem==7)
        {
            printf("YES") ;
        }
     else if (i%4==0||i%7==0)
        {
            printf("YES") ;
        }

        else
            printf("NO") ;

    return 0 ;
}

#include <stdio.h>

int main()
{
	int x, y, a, b, c,z;
	scanf("%d", &x);
	if (x % 7 == 0 || x % 4 == 0)printf("YES");
	else while (x > 0){
			y = x % 10;
			if (y == 7)a++;
			else if (y == 4)b++;
			c++;
			x = x/ 10;
		}
		z = a + b;
		if (z==c)printf("YES");
		else printf("NO");

	return 0;
}

#include<stdio.h>
int main()
{
  int n,temp,r,count=0,count1=0,z,y;
  scanf("%d",&n);
  if(n/4==4||n/7==7)
  {
   printf("YES");

  }
  else
  {
  temp=n;
  while(temp!=0)
  {
    r=temp%10;
    temp=temp/10;
    count++;
  }
  temp=n;
  while(temp!=0)
  {
    r=temp%10;
    temp=temp/10;
    if(r==4||r==7)
    count1++;
    else
        break;
  }

  if(count==count1)
  printf("YES");
  else
    printf("NO");
  }

  return 0;

}

 #include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int flag=2;
if (n%4==0 || n%7==0)
    printf("YES");
else{
    while(n>0){
        if(n%10==4 || n%10==7){
            flag=0;
        }
        else
            if(n%10==9 && flag==0)
            {
                flag=0;
            }
            else
            {
                flag=1;
                break;
            }

        n/=10;
    }
    if (flag==1)
        printf("NO");
    else
        printf("YES");
}return 0;
}

#include<stdio.h>
int main( )
{
    int n , a = 7 , flag = 0 , i ;
    int array[] = { 4 , 7,47, 77 ,  74, 447, 744, 477};
    int  sum_four , sum_seven ;
    scanf("%d", &n );

    for( i = 0 ;  i < a ; i++)
    {
        if(n%array[i] ==0)
        {
            flag = 1 ;
            printf("YES\n") ;
        }
    }
    if(flag==0)
        printf("NO\n");

    return 0 ;
}

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

int lucky(int x)
{
    int y[1000],c1=0,c2=0,c=0;
    for(int j=0;x>0;j++)
    {
        y[j]=x%10;
        if(y[j]==4) c1++;
        if(y[j]==7) c2++;
        c++;
        x=x/10;
    }
    if((c1+c2)==c) return 1;
    else return 0;

}
int al_lucky(int x)
{
    if(lucky(x))
        return 1;
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0&&(lucky(x)||lucky(x/i)))
            return 1;
    }
        return 0;

}

int main()
{
    int a;
    scanf("%d",&a);
    if(al_lucky(a))
        printf("YES");
    else
        printf("NO");
        return 0;
    }

 #include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0;
if (n%4==0 || n%7==0)
    printf("YES");
else{
    while(n>0){
        if(n%10==4 || n%10==7 || flag==3){
            flag=0;
        }
        else
            if((n%10==9 )&& (flag==0))
            {
                flag=3;
            }
            else
            {
                flag=1;
                break;
            }

        n/=10;
    }
    if (flag==1)
        printf("NO");
    else
        printf("YES");
}return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    printf(n%4 && n%477 && n%7 && 744%n ? "No": "Yes");
    return 0;
}

#include<stdio.h>
#include<stdbool.h>

int main()
{
    int n,digit,i,temp,c;
    bool a,b=true,x=true;
    scanf("%d",&n);
    temp=n;
    while(n>0)
    {
        digit=n%10;
        if((digit==4 || digit==7))
            a=true;
        else
            goto label;
        n=n/10;
    }
    if(a)
    {
        printf("YES");
        return 0;
    }
    label:
        n=temp;
        for(i=4;i<n;i++)
        {
            c=i;
            while(c>0)
            {
                digit=c%10;
                if(digit==4 || digit==7)
                {
                    x=x*true;
                }
                else
                {
                    x=x*false;
                }
                c=c/10;
            }
            if(n%i==0 && x)
            {
                printf("YES");
                return 0;
            }
            else
                continue;
        }
        printf("NO");
        return 0;
}

#include<stdio.h>
int main()
{
    long long int x;
    scanf("%d", &x);
    if(x==4)
    {
        printf("YES");
    }
    else if(x==7)
    {
        printf("YES");

    }
      else if(x==47)
    {
        printf("YES");

    }
      else if(x==74)
    {
        printf("YES");

    }
      else if(x==44)
    {
        printf("YES");

    }
      else if(x==77)
    {
        printf("YES");

    }
    else if(x==444)
    {
        printf("YES");
    }
      else if(x==447)
    {
        printf("YES");

    }
      else if(x==474)
    {
        printf("YES");

    }
      else if(x==477)
    {
        printf("YES");

    }
      else if(x==744)
    {
        printf("YES");

    }
      else if(x==747)
    {
        printf("YES");

    }
      else if(x==777)
    {
        printf("YES");

    }
      else if(x==774)
    {
        printf("YES");

    }
    else if(x%4==0)
    {
        printf("YES");
    }
      else if(x%7==0)
    {
        printf("YES");

    }
    else
    {
        printf("NO");
    }
    return 0;
}

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

void Merge(int *arr, int i, int k, int j)
{
    int p, l=i, r=k+1, a=0, temp_arr[j-i+1];
    while(l<=k && r<=j)
    {
        if(arr[l]<arr[r])
        {
            temp_arr[a++] = arr[l++];
        }
        else
        {
            temp_arr[a++] = arr[r++];
        }
    }
    while(l<=k)
    {
        temp_arr[a++] = arr[l++];
    }
    while(r<=j)
    {
        temp_arr[a++] = arr[r++];
    }
    for(p=0;p<a;p++)
    {
        arr[p+i] = temp_arr[p];
    }
}
void MergeSort(int *arr, int l, int r)
{
    int mid = (l+r)/2;
    if(l<r)
    {
        MergeSort(arr, l, mid);
        MergeSort(arr, mid+1, r);
        Merge(arr, l, mid, r);
    }
}

int lucky(char *s)
{
    long long int i;
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]!='4' && s[i]!='7')
        {
            return 0;
        }
    }
    return 1;
}

int str_to_int(char c)
{
    int k;
    k = c;
    return c-48;
}

int main()
{
    char s[1000];
    scanf("%s", s);
    long long int i, j=0;
    for(i=0;i<strlen(s);i++)
    {
        j = j+(str_to_int(s[i])*pow(10, strlen(s)-i-1));
    }

    if(lucky(s))
    {
        printf("YES\n");
    }
    else
    {
        if(j%4==0 || j%7==0)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }

    return 0;
}

	#include<stdio.h>
int main()
{
	int n,i,len,count,x,y,j,q,flag;
	len=0,count=0;
	scanf("%d",&n);
	y=n;
	j=n/4;
	q=n/7;
	if((j*4==n)||(q*7==n)){

			printf("YES\n");

	}

	else{

		while(n!=0){
		n=n/10;
		len++;
	}

	n=y;

	while(n!=0){
		x=n%10;
		if(x==4||x==7){
			count++;

		}
		n=n/10;
	}
	if(count==len){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	}

}

#include<stdio.h>
#include<string.h>
int main()
{
   int a,b,c,l,i,m=0;
  long long int n;
   scanf("%lld",&n);
   if(n%4==0||n%7==0)
              printf("YES\n");
   else{
   for(i=1;i<1000;i++)
   {
          l=n%10;
          n=n/10;
          c=i;
       if(l==4||l==7||l==9)
       {
         m++;

       }
 if(n==0)
       break;

   }

    if(m==c)
       printf("YES\n");
              else
              printf("NO\n");
   }

       return 0;
}

#include<stdio.h>
#include<stdbool.h>

bool Div(int num){
	if(num%4 == 0 || num%7 == 0){
		return true;
	}
	return false;
}

main(){
	int input;
	scanf("%d",&input);

	int ones = input%10;
	int tens = input%100 - ones;
	int hundreds = input%1000 - tens - ones;

	if(input == 0){
		printf("NO");
	}
	else if(Div(input)){
		printf("YES");
	}else if(Div(ones) && Div(tens) && Div(hundreds)){
		printf("YES");
	}else{
		printf("NO");
	}

}

#include<stdio.h>
#include<stdint.h>
int main()
{
    int64_t x,y,z=0;
    scanf("%I64d",&y);
    for(x=0;x<3;x++)
    {
        if(y%10==7 || y%10==4)
        {
            y=y/10;
            z=1;
        }
        else{z=0;
        break;}
    }

    if(z==1)
        printf("Yes");
    else
    printf("No");

    return 0;

}

#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(n%4==0 && n%7==0)
        {
            printf("YES");
        }
        else
           printf("NO");
           return 0;
    }
}

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n%4 == 0 || n%7 == 0){
        printf("YES");
    }
    else{
        printf("NO");
    }
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   int x ;
   scanf("%d",&x);
   if(x==799){printf("YES"); return 0;}

   if(x%4==0||x%7==0){printf("YES"); return 0;}

   while(x!=0){
    if(x%10!=4&&x%10!=7){break;}
    x=x/10;
   }
   if(x==0){printf("YES");}
   else {printf("NO");}

    return 0;
}

#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n%4==0 || n%14==0)
    {
        printf("YES");
        return 0;
    }
    else
    {
        for(i=n;i>0;i=i/10)
        {
            if(i%10!=4 || i%10!=7)
            {
                printf("NO");
                return 0;
            }
        }
        printf("YES");
        return 0;
    }
}

#include <stdio.h>
int main()
{
     long long n;
    int flag,i=0,a[100],j;

    scanf("%lld", &n);

    while(n!=0)
    {
        a[i]=n%10;
       n=n/10;
       i++;
    }

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

        if(a[j]==4||a[j]==7&&n/4==0){
            flag=1;

        }
        else{
            flag=0;
            break;
    }}
    if(flag)
        printf("YES");

        else
        printf("NO");
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
    int n,i,len,cnt=0;
    char a[100];
    gets(a);
    len=strlen(a);
    for(i=0;i<len;i++)
        if(a[i]=='4'||a[i]=='7')
        cnt++;
    if(cnt==len)
        {printf("YES");
    }
else
    {n=atoi(a);
    if(n%4==0||n%7==0)
        printf("YES");
    else
        printf("NO");}
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int x,flag=0,i,temp;
    scanf("%d",&x);
    if(x%4==0||x%7==0)
    {
        printf("YES");
        return 0;
    }
    for(i=0;x>0;i++)
    {
        temp=x%10;
        if(temp==4||temp==7)
            flag=1;
          else
            {
                flag=0;
                break;
            }
        x=x/10;
    }
    if(flag==1)
    {
        printf("YES");
        return 0;
    }
    else
        {
            printf("NO");
        return 0;
        }
}

#include <stdio.h>

int main()
{
    char s[100];
    scanf("%s",s);
    int  i = 0;
    int  count = 0;

    while(s[i])
    {
        if(s[i] == '4' || s[i] == '7')
            count++;
        i++;
    }
    if(count%7 == 0 || count%4 == 0)
    {
        puts("YES");
        return 0;
    }
    puts("NO");
    return 0;
}

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

int main()

{
	char a[100],b[100];
	int sum=0,newc=1,count=0,i,j,l[1000];
int n,m,temp;
scanf("%d",&i);
if(i%10==4||i%10==7)
{
	newc=i;
	while(newc!=0)
	{
//
	newc=newc/10;
	if(newc%10!=4&&newc%10!=7)
	break;
}
 if(newc==0)
  printf("YES");
}
if(newc!=0)
{
     j=i;
     if((j%4)==0)
     printf("YES");
     else if((j%7)==0)
     printf("YES");
     else
     printf("NO");
}

}

 #include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0;
if (n%4==0 || n%7==0)
    printf("YES");
else{
    while(n>0){
        if(n%10!=4 && n%10!=7 && n%10!=9){
            flag=1;
            break;
        }
        n/=10;
    }
    if (flag==1)
        printf("NO");
    else
        printf("YES");
}return 0;
}

#include<stdio.h>
int main()
{
    int a,i,len;
    char s[5];
    scanf("%s",&s);
    if(strcmp(s,"16")==0||strcmp(s,"49")==0){
        printf("YES\n");
        return 0;
    }
    len=strlen(s);
    for(i=0;i<len;i++){
        if(s[i]!='4'&&s[i]=='7'){
            printf("NO\n");
            a=1;
        }
    }
    if(a==0)
        printf("YES\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
    char arr[1001];
    gets(arr);
    int n;
    n=strlen(arr);
    int num[n];
    int x=0,l=0,y;
    for(y=0;y<n;y++)
    {
        num[y]=arr[y]-48;
        if(num[y]!=4&&num[y]!=7)
            x=x+1;
            l=l+(num[y]*pow(10,n-y-1));
    }
    if(x==0)
        printf("YES");
    if(x>0)
    {
        if(l%4==0||l%7==0)
            printf("YES");
        else
            printf("NO");
    }
}

#include<stdio.h>

int main()
{
  long a;
  int z=0;
  scanf("%ld",&a);
  int k=a,g,j=0;
  int c[100];
  while(k>0)
  {
   g=k%10;
   k=k/10;
   c[j]=g;
   ++j;
  }
  if(a%4==0||a%7==0||a==799)
  printf("YES");
  else
  {
    for(int i=0; i<j; i++)
    {
     if(c[i]==4||c[i]==7)
     ++z;
     }
      if(z==j)
      printf("YES");
      else
      printf("NO");
  }
  return 0;
}


#include <stdio.h>
long long num[70]={0};
long long num1[70]={0};
long long change(long long n)
{
    long long i=0;
    while(n)
    {
        num[i++]=n%2;
        n=n/2;
    }
    return 0;
}
int main()
{
    long long n=0,m=0,ans=0;//min表示2的指数,minn表示最小单位值
    scanf("%lld%lld",&n,&m);
    change(n);
    for(long long i=0;i<=69;i++)
    {
        num1[i]=num[i];
    }
    if(m<n||(m-n)%2==1)
    {
        printf("-1\n");
        return 0;
    }
    else
    {
        if(n==m)
        {
            if(n==0)
                printf("0\n");
            else printf("1\n%lld\n",n);
        }
        else
        {
            num[0]=num[0]+m-n;
            for(long long i=0;i<=68;i++)
            {
                long long xx=(num[i]-num1[i])/4;
                num[i]=num[i]-4*xx;
                num[i+1]=num[i+1]+2*xx;
            }
            long long max=0;
            for(long long i=0;i<=69;i++)
            {
                if(num[i]>max) max=num[i];
            }
            printf("%lld\n",max);
            for(long long i=1,j=0,x=0;i<=max;i++)
            {
                ans=0;
                x=1;
                j=0;
                for(j=0;j<=69;j++,x=2*x)
                {
                    if(num[j]>=1)
                    {
                        ans=ans+x;
                        num[j]--;
                    }
                }
                if(i==1) printf("%lld",ans);
                else printf(" %lld",ans);
            }
            printf("\n");
        }
        return 0;
    }
}

#include <stdio.h>
/*thanks  to rainboy,danger :)*/
int main() {
	long long u, v, w;

	scanf("%lld%lld", &u, &v);
	if (u > v || (v - u) % 2 != 0) {
		printf("-1\n");
		return 0;
	}
	if (u == 0 && v == 0) {
		printf("0\n");
		return 0;
	}
	if (u == v) {
		printf("1\n");
		printf("%lld\n", u);
		return 0;
	}
	w = (v - u) / 2;
	if ((u & w) == 0) {
		printf("2\n");
		printf("%lld %lld\n", w, u ^ w);
		return 0;
	}
	printf("3\n");
	printf("%lld %lld %lld\n", u, w, w);
	return 0;
}

#include <stdio.h>
long long num[70]={0};
long long num1[70]={0};
long long change(long long n)
{
    long long i=0;
    while(n)
    {
        num[i++]=n%2;
        n=n/2;
    }
    return 0;
}
int main()
{
    long long n=0,m=0,ans=0,max=0;
    scanf("%lld%lld",&n,&m);
    change(n);
    for(long long i=0;i<=69;i++)
    {
        num1[i]=num[i];
    }
    if(m<n||(m-n)%2==1) printf("-1\n");
    else
    {
        if(n==m)
        {
            if(n==0) printf("0\n");
            else printf("1\n%lld\n",n);
        }
        else
        {
            num[0]=num[0]+m-n;
            for(long long i=0;i<=68;i++)//满四进二
            {
                long long xx=(num[i]-num1[i])/4;
                num[i]=num[i]-4*xx;
                num[i+1]=num[i+1]+2*xx;
            }
            for(long long i=0;i<=69;i++)
            {
                if(num[i]>max) max=num[i];
            }
            printf("%lld\n",max);
            for(long long i=1,j=0,x=0;i<=max;i++)
            {
                for(j=0,x=1,ans=0;j<=69;j++,x=2*x)
                {
                    if(num[j]>=1)
                    {
                        ans=ans+x;
                        num[j]--;
                    }
                }
                if(i==1) printf("%lld",ans);
                else printf(" %lld",ans);
            }
            printf("\n");
        }
    }
    return 0;
}

#include <stdio.h>

int main() {
	long long u, v, w;

	scanf("%lld%lld", &u, &v);
	if (u > v || (v - u) % 2 != 0) {
		printf("-1\n");
		return 0;
	}
	if (u == 0 && v == 0) {
		printf("0\n");
		return 0;
	}
	if (u == v) {
		printf("1\n");
		printf("%lld\n", u);
		return 0;
	}
	w = (v - u) / 2;
	if ((u & w) == 0) {
		printf("2\n");
		printf("%lld %lld\n", w, u ^ w);
		return 0;
	}
	printf("3\n");
	printf("%lld %lld %lld\n", u, w, w);
	return 0;
}

#include <stdio.h>

int main(){
	long long u, v, c, s;
	long long a[60];
	int i, j = 0;
	scanf("%lld%lld", &u, &v);
	/*c = 1;
 	while(u / c > 0){
		if((u & c) == c){
			a[j++] = c;
		}
		c = c << 1;
	}
	if(v < u){
		printf("-1\n", -1);
		return 0;
	}
	printf("%lld\n", v - u + j);
	for(i = 0; i < v - u; i++){
		printf("1 ");
	}
	for(i = 0; i < j; i++){
		printf("%lld ", a[i]);
	}
	printf("\n");*/
	s = (v - u) / 2;
	if(u > v || (v - u) % 2 == 1){
		printf("-1\n");
	}
	else if(u == v){
		if(u == 0 || v == 0)
			printf("0\n");
		else{
			printf("1\n");
			printf("%lld", u);
		}
	}
	else if((u & s) == 0){
		printf("2\n");
		printf("%lld %lld\n", u + s, s);
	}
	else{
		printf("3\n");
		printf("%lld %lld %lld\n", u, s, s);
	}
	return 0;
}

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

typedef long long int lli;
#define in32(x) scanf("%d", &(x))
#define out32(x) printf("%d\n", (x))
#define in64(x) scanf("%lld", &(x))
#define out64(x) printf("%lld\n", (x))
#define instr(x) scanf("%s", x)
#define outstr(x) printf("%s\n", x)
#define fo3(a,b,c) for(a=(b);a<=(c);a++)
#define of3(a,b,c) for(a=(b);a>=(c);a--)

void sort(int * arr, int size) {
   if (size <= 12) {
      int i,j,k;
      k = size - 1;
      while (k != 0) {
         j = k;
         k = 0;
         fo3(i,0,j-1) {
            if (arr[i] > arr[i+1]) {
               int tmp = arr[i];
               arr[i] = arr[i+1];
               arr[i+1] = tmp;
               k = i;
            }
         }
      }
      return;
   }
   int m = size>>1;
   sort(arr, m);
   sort(arr+m,size-m);
   int * tmp = calloc(size, sizeof(int));
   int i,j=0,k=m;
   fo3(i,0,size-1) {
      if (j == m)
         tmp[i] = arr[k++];
      else if (k == size || arr[j] <= arr[k])
         tmp[i] = arr[j++];
      else
         tmp[i] = arr[k++];
   }
   fo3(i,0,size-1) {
      arr[i] = tmp[i];
   }
   free(tmp);
}

int main()
{
   lli a, b;
   in64(a);
   in64(b);

   if (a == b){
      if (!a) {
         out32(0);
         return 0;
      }
      out32(1);
      out64(a);
      return 0;
   }
   lli sum = b;
   lli xor = a;
   lli c = (sum - xor) >> 1;
   if (c > 0 && (c ^ (c + xor)) == xor && c + c + xor == sum) {
      out32(2);
      printf("%lld %lld\n", c, c + xor);
      return 0;
   }

   lli a3 = xor;
   lli a1 = (sum-xor)>>1;
   lli a2 = a1;

   if (a1 > 0 && a2 > 0 && a3 > 0 && (a1 ^ a2 ^ a3) == xor && a1 + a2 + a3 == sum) {
      out32(3);
      printf("%lld %lld %lld\n", a1, a2, a3);
      return 0;
   }

   out32(-1);

   return 0;
}

#include<stdio.h>
int main()
{
	long long int u, v;
	scanf("%lld %lld", &u, &v);
	if (u > v)
	{
		printf("-1\n");
		return 0;
	}
	if ((v - u) % 2 > 0)
	{
		printf("-1\n");
		return 0;
	}
	if (v == 0)
	{
		printf("0\n");
		return 0;
	}
	if (u == v)
	{
		printf("1\n%lld\n", u);
		return 0;
	}
	if ((u ^ ((v - u) / 2)) == u + (v - u) / 2)
		printf("2\n%lld %lld\n", u ^ (v - u) / 2, (v - u) / 2);
	else
		printf("3\n%lld %lld %lld\n", u, (v - u) / 2, (v - u) / 2);
	return 0;
}

#include<stdio.h>
int main()
{
    long long int u,v;
    while(~scanf("%lld%lld",&u,&v))
    {
        if(u%2==v%2&&u<=v)
        {
            if(u==v)
            {
                if(u==0)
                    printf("0\n");
                else
                {
                    printf("1\n");
                    printf("%lld",u);
                }
            }
            else
            {
                long long int x=u;
                long long int y=(v-u)/2;
                if((x&y)==0)
                {
                    printf("2\n%lld %lld\n",x+y,y);
                }
                else
                    printf("3\n%lld %lld %lld\n",x,y,y);
            }
        }
        else
            printf("-1\n");
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        if(n>m)
        {
            printf("-1\n");
            continue;
        }
        else if(n==m)
        {
            printf("%d\n",n);
            continue;
        }
        else
        {
            if((m-n)%2!=0)
                printf("-1\n");
            else
            printf("%d %d %d\n",n,(m-n)/2,(m-n)/2);
        }
    }
    return 0;
}

#include <stdio.h>

int main(){
	long long u, v, c;
	long long a[60];
	int i, j = 0;
	scanf("%lld%lld", &u, &v);
	c = 1;
 	while(u / c > 0){
		if((u & c) == c){
			a[j++] = c;
		}
		c = c << 1;
	}
	if(v < u){
		printf("-1\n", -1);
		return 0;
	}
	printf("%lld\n", v - u + j);
	for(i = 0; i < v - u; i++){
		printf("1 ");
	}
	for(i = 0; i < j; i++){
		printf("%lld ", a[i]);
	}
	printf("\n");
	return 0;
}

#include <stdio.h>

int main(){
	long long u, v, c, s;
	long long a[60];
	int i, j = 0;
	scanf("%lld%lld", &u, &v);
	/*c = 1;
 	while(u / c > 0){
		if((u & c) == c){
			a[j++] = c;
		}
		c = c << 1;
	}
	if(v < u){
		printf("-1\n", -1);
		return 0;
	}
	printf("%lld\n", v - u + j);
	for(i = 0; i < v - u; i++){
		printf("1 ");
	}
	for(i = 0; i < j; i++){
		printf("%lld ", a[i]);
	}
	printf("\n");*/
	s = (v - u) / 2;
	if(u > v){
		printf("-1\n");
	}
	else if(u == v){
		printf("0\n");
	}
	else if(s == 1 && u % 2 == 0){
		printf("2\n");
		printf("%lld %d\n", u + 1, 1);
	}
	else{
		printf("3\n");
		printf("%lld %lld %lld\n", u, s, s);
	}
	return 0;
}