Problem: 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

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Algotic {
	public static void f722_a() throws IOException {
//		Scanner sc = new Scanner(System.in);
		BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out);
	    int type = Integer.parseInt(sc.readLine());
	    
	    String time = sc.readLine();
	    
//	    out.println(time+"12");
//	    if(true) return ;
	    int deqF = Integer.parseInt(time.substring(3,5));
	    if(deqF >= 60 ) //|| Integer.parseInt(time.substring(4,5)) != 0
	    	time = time.substring(0, 3) + "5" + time.substring(4,5);
//	    else if(deqF == 6 && Integer.parseInt(time.substring(4,5)) != 0)
	    int hour1 = Integer.parseInt(time.substring(0,1));
	    int hour = Integer.parseInt(time.substring(0,2));
	    if(type == 12) {
	    	if(hour1 == 1) {
	    		if(Integer.parseInt(time.substring(1,2)) > 2)
	    			time = time.substring(0, 1) + "1" + time.substring(2);
	    	}
	    	else if(hour1 == 0) {
	    		if(Integer.parseInt(time.substring(1,2)) == 0)
	    			time = time.substring(0, 1) + "1" + time.substring(2);
	    	}
	    	else if(Integer.parseInt(time.substring(0,2)) > 12) {
	    		if(Integer.parseInt(time.substring(1,2)) == 0)
	    			time = "1" + time.substring(1, 2) + time.substring(2);
	    		else 
	    			time = "0" + time.substring(1, 2) + time.substring(2);
	    	}
	    } else if (type == 24) {
	    	if(hour >= 24)
	    		time = "1" + time.substring(1, 2) + time.substring(2);
	    }
	    out.println(time);
	    out.close();
	    sc.close();
	}
	public static void f679_a() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    
	    int [] arr = {
	    		2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
	    };
	    int um = 0;
	    
	    int [] arr2 = {
	    		4,9,25,49
	    };
	    
	    outerloop:
	    for(int i=0; i<arr.length; i++) {
	    	System.out.println(arr[i]);
	    	System.out.flush();
	    	if(sc.next().equals("yes")) {
	    		um++;
	    		if(um>=2) {
	    			out.println("composite");
	    			break;
	    		} else {
//	    			if(Arrays.asList(arg0))
	    			for(int j=0; j<arr2.length; j++) {
	    		    	System.out.println(arr2[j]);
	    		    	System.out.flush();
	    		    	if(sc.next().equals("yes")) {
	    		    		
	    		    			out.println("composite");
	    		    			um = 298;
	    		    			break outerloop;
	    		    		
	    		    	}
	    		    }
	    		}
	    	}
	    }
	    if(um < 2)
			out.println("prime");
	    
	    out.close();
	    sc.close();
	}
	
	public static void f702_a() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    
	   int n = sc.nextInt();
	   long l1 = 0;
	   long l2 = 0;
	   int counter = 0;
	   int maxCounter = 0;
	   for(int i=0; i<n; i++) {
		   l2 = sc.nextInt();
		   if(l2 > l1) {
			   counter++;
			   if(counter > maxCounter)
				   maxCounter=counter;
			   
		   } else {
			   counter = 1;
		   }
		   l1 = l2;
	   }
	    out.println(maxCounter);
	    out.close();
	    sc.close();
	}
	
	public static void f702_b() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    
	    ArrayList<Double> stepens2 = new ArrayList<Double>();
	    long res=0;
	   int n = sc.nextInt();
	   double [] numbers = new double[n];
	   for(long i=0; i<n; i++) {
		   numbers[(int) i] = sc.nextInt();
	   }
	   long lastStepen = 0;
	    for(long i=0; i<n; i++) {
	    	for1:  for(long j=i+1; j<n; j++) {
			   double key = numbers[(int) i] + numbers[(int) j];
			   if(stepens2.contains(key))
				   res++;
			   else  {
				   for2 : while(true) {
					   double res2;
					   res2 = key;
					   if((res2 % 2) != 0) {
						   if((res2 / 2) != 0) {
							   // ne 1 deyil nedeki cut
							   
						   }
					   }
					   res2 = res / 2;
					   lastStepen++;
					   double kk = Math.pow(2, lastStepen);
					   stepens2.add(kk);
					   if(kk == key) {
						   res++;
						   continue for1;
					   } else if(kk>key) {
						   break for2;
					   }
				   }
			   }
		   }
	   }
	    out.println(res);
	    out.close();
	    sc.close();
	}
	
	public static void main(String [] args) throws IOException {
		f722_a();
	}
	
	public static void f709_a() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    int n, b, d = 0;
	    n = sc.nextInt();
	    b = sc.nextInt();
	    d = sc.nextInt();
	    int k=0;
	    int res = 0;
	    int bSum = 0, dSum=0;
	    for(int i=0; i<n; i++) {
	    	k = sc.nextInt();
	    	if(k>b)
	    		continue;
	    	dSum += k;
	    	if(dSum > d) {
	    		dSum = 0;
	    		res++;
	    	}
	    }
	    
	    
		out.println(res);
	    out.close();
	    sc.close();
	}
	
	
	public static void f711_a() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    int n = 0;
	    n = sc.nextInt();
	    String [] bus = new String[n];
	    String row = "";
	    boolean res = false;
	    sc.nextLine();
	    for(int i=0; i<n; i++) {
	    	row = sc.nextLine();
	    	if(row.contains("OO") && !res) {
	    			row = row.replaceFirst("OO", "++");
	    		res = true;
	    	}
	    	bus[i] = row;
	    }
	    if(res) {
	    	out.println("YES");
	    	for(int i=0; i<n; i++) 
	    		out.println(bus[i]);
	    }
	    else out.println("NO");
	    out.println();
	    out.close();
	    sc.close();
	}
	public static void f710_a() {
		Scanner sc = new Scanner(System.in);
	    PrintWriter out = new PrintWriter(System.out);
	    
	   String n = sc.nextLine();
	   n = n.trim();
	   int res = 8;
	   if(n.substring(0,1).equals("a") || n.substring(0,1).equals("h") ) {
		   if(n.substring(1, 2).equals("1") || n.substring(1, 2).equals("8"))
			res = 3;
		   else res = 5;
	   } else if(n.substring(1, 2).equals("1") || n.substring(1, 2).equals("8")) {
		   res = 5;
	   }
	   else res = 8;
	   out.println(res+"");
	    out.close();
	    sc.close();
	}
}