You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.

You are given a time in format HH:MM that is currently displayed on the broken clock. Your goal is to change minimum number of digits in order to make clocks display the correct time in the given format.

For example, if 00:99 is displayed, it is enough to replace the second 9 with 3 in order to get 00:39 that is a correct time in 24-hours format. However, to make 00:99 correct in 12-hours format, one has to change at least two digits. Additionally to the first change one can replace the second 0 with 1 and obtain 01:39.

Input

The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively.

The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.

Output

The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.

Examples

Input
24
17:30
Output
17:30
Input
12
17:30
Output
07:30
Input
24
99:99
Output
09:09
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std; int main()
{
int n,a,b;
scanf("%d %d:%d",&n,&a,&b);
while(b>=)
{
b%=;
}
if(n==)
{
while(a>=)
{
a%=;
}
}
else if(n==)
{
while(a>)
{
a-=;
}
if(a==)
a++;
}
printf("%02d:%02d\n",a,b);
}

最新文章

  1. 4541: [Hnoi2016]矿区
  2. 精通Web Analytics 2.0 (6) 第四章:点击流分析的奇妙世界:实际的解决方案
  3. Java enum的用法详解[转]
  4. 1 error C4996: &#39;pcl::SAC_SAMPLE_SIZE&#39;:
  5. BCB中实现拖拽Panel 改变位置和大小的代码
  6. segmentation fault
  7. Unity3D实现赛车的灯光效果
  8. Synchronizing with Remote Repositories
  9. LinqToDataTable
  10. 如何修改linux时间? 校正linux系统的时间
  11. 部署vc2008开发的程序(vcredist_x86是其中一个办法)
  12. hdu 1875 畅通project再续
  13. keydown - &gt; keypress - &gt; keyup
  14. 使用 纯JQuery 进行 表单 验证
  15. 浅析PHP正则表达式的利用技巧
  16. Recycle----项目总结
  17. 3.9 run_main.py源码(兼容python2和3)
  18. MySQL 占用cpu 100%
  19. eclipse gradle插件 org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from &#39;https://services.gradle.org/distributions/gradle-3.4-bin.zip&#39;.
  20. JAR 介绍-百度百科

热门文章

  1. Kaggle 数据挖掘比赛经验分享(转)
  2. Android控件——TextView,EditText
  3. Tabular DataStream protocol 协议
  4. 【bzoj4448】SCOI2015 情报传递
  5. C基础 时间业务实战代码
  6. HTML5API(3)
  7. webIcon
  8. PHP定界符出现错误
  9. APP线上问题收集信息整理
  10. Table上下滚动