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.*;
import java.math.BigInteger;
import java.util.*;


public class JavaApplication7 {
  static  int dr [] = {0,0,1,-1} ;
  static  int dc [] = {1,-1,0,0};
  static int n , m;     
  static char ar [][];
  static  boolean vi [][] ;
static void dfs(int x , int y ,char c)
{
  for(int i = 0 ; i < dr.length; i++)
  { int r = dr[i] + x ; int co = dc[i] + y;
    if(r < n && r >= 0 && co < m && co >=0 && !vi[r][co] && ar[r][co] == '.')
    {vi[r][co] = true ;
     ar[r][co] = c ;
     dfs(r,co,c) ;
    }
  }

}



static int count = 0;
static void dfs(int x , int y )
{
  for(int i = 0 ; i < dr.length; i++)
  { int r = dr[i] + x ; int co = dc[i] + y;
    if(r < n && r >= 0 && co < m && co >=0 && !vi[r][co] && ar[r][co] == '.')
    {vi[r][co] = true ;
     count++;
     dfs(r,co) ;
    }
  }

}
static void dfs2(int x , int y )
{
  for(int i = 0 ; i < dr.length; i++)
  { int r = dr[i] + x ; int co = dc[i] + y;
       
    if(r < n && r >= 0 && co < m && co >= 0 && ar[r][co] == '.')
    {
     vi[r][co] = true ;
     count++;
     ar[r][co] = '*' ;
      
     dfs2(r,co) ;
    }
  }

}
    public static void main(String[] args) throws Exception
    {
      Reader.init(System.in);
      int n = Reader.nextInt() ;
      String s = Reader.next();
      String x ;
      String ans = "" ;
      int min = 4564 ;
      if(n == 24)
          for(int i = 0 ; i < 3 ; i++)
              if(i != 2)
              {    
                  for(int j = 0 ; j < 10 ; j++)
                  for(int q = 0 ; q < 6 ; q++)
                      for(int z = 0 ; z < 10 ; z++ )
                      {
                         
                         x =i+""+j+":"+q+""+z; 
                      int t = 0;
                      
                      for(int w = 0 ; w < 5 ; w++)
                          if(s.charAt(w) != x.charAt(w))
                              t++;
                      
                      if(t < min)
                      {
                      min = t ;
                      ans = x ;
                      }     
                      }}
              else for(int j = 0 ; j < 4 ; j++)
                    for(int q = 0 ; q < 6 ; q++)
                      for(int z = 0 ; z < 10 ; z++ )
                      {x =i+""+j+":"+q+""+z; 
                      
                      int t = 0;
                      for(int w = 0 ; w < 5 ; w++)
                          if(s.charAt(w) != x.charAt(w))
                              t++;
                      if(t < min)
                      {
                      min = t ;
                      ans = x ;
                      }     
                      }
      
       if(n == 12)
              for(int i = 0 ; i < 2 ; i++)
              if(i == 0)
              {  
                  for(int j = 1 ; j < 10 ; j++)
                  for(int q = 0 ; q < 6 ; q++)
                      for(int z = 0 ; z < 10 ; z++ )
                      {
                          x =i+""+j+":"+q+""+z; 
                          
                      int t = 0;
                      
                      for(int w = 0 ; w < 5 ; w++)
                          if(s.charAt(w) != x.charAt(w))
                              t++;
                      
                      if(t < min)
                      {
                      min = t ;
                      ans = x ;
                      }     
                      }}
              else for(int j = 0 ; j < 3 ; j++)
                    for(int q = 0 ; q < 6 ; q++)
                      for(int z = 0 ; z < 10 ; z++ )
                      {x =i+""+j+":"+q+""+z; 
                         
                      int t = 0;
                      for(int w = 0 ; w < 5 ; w++)
                          if(s.charAt(w) != x.charAt(w))
                              t++;
                      if(t < min)
                      {
                      min = t ;
                      ans = x ;
                      }     
                      }
      
           
           
        System.out.println(ans);
                        
    }
       
}
        
    
    
    class pair implements Comparable<pair>
    {
     int  mod,pr , w; 
     int  san ; 
    pair( int b  , int x)
    {
   
    
    
    mod = b ;
    san = x ;
  
    }
    @Override
    public int compareTo(pair t) {
        if(t.pr <pr)
            return 1 ;
        else if(t.pr > pr) return -1 ;
        else return 0 ;
    }
    
    
    
    }

   
    
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

   
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException{
    return Long.parseLong(next()) ;
    }
}